Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share: handle rows concurrently #241

Merged
merged 8 commits into from
Jan 6, 2022

Conversation

vgonkivs
Copy link
Member

  • Handle multiple rows concurrently;

Closes #184

Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vgonkivs, thank you for working on this. Unfortunately, this is wrong and I'll try to explain why.

service/share/share.go Outdated Show resolved Hide resolved
service/share/share.go Outdated Show resolved Hide resolved
@renaynay renaynay added this to In progress in March 2022 Testnet [ DEPRECATED IN FAVOUR OF BETA ] via automation Nov 29, 2021
@renaynay renaynay moved this from In progress to In review in March 2022 Testnet [ DEPRECATED IN FAVOUR OF BETA ] Nov 30, 2021
@renaynay renaynay added the area:shares Shares and samples label Nov 30, 2021
@renaynay
Copy link
Member

renaynay commented Dec 1, 2021

@vgonkivs Thank you very much for this PR - would you be able to take a first shot at writing a test for this?

service/share/share.go Outdated Show resolved Hide resolved
Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revisit this: https://github.com/celestiaorg/celestia-node/pull/241/files#r760551422

I think it would be good to add a benchmark that shows that this parallelization is justified (though it is relatively obvious that it should be faster but still).

would you be able to take a first shot at writing a test for this?

The benchmark could also serve as a test. The current tests do not yet test multiple rows (thx @renaynay for point this out).

func TestService_GetSharesByNamespace(t *testing.T) {

@vgonkivs
Copy link
Member Author

vgonkivs commented Dec 5, 2021

Hi @renaynay , @liamsi . Thanks for the idea to add benchmarks and additional tests. I will try to provide them within next week.

@Wondertan
Copy link
Member

I think it would be good to add a benchmark that shows that this parallelization is justified (though it is relatively obvious that it should be faster but still).

@liamsi, the optimization is not CPU bound, i.e. we don't parallelize something calculation intensive, but we parallelize IO bound logic, so parallelization is furthermore a wrong word here, while concurrency is a right one(like it is said in PR name). Thus, we might not see any performance improvements and even performance degradation when we mock out network responses.

Particularly, here we start traversing and requesting each row concurrently, instead of doing them in order. Imagine sending 10 network requests in order and compare this to spawning 10 concurrent goroutines. In order requires for n+1 request to wait for n response to land first, while sending concurrently allows requests to be sent independently. In the mock environment, where responses are immediate, goroutines may only add overhead, as there are no responses to wait for.

@vgonkivs
Copy link
Member Author

Thanks for the explanation @Wondertan. I was a bit confused after I had received the results - the code really works slower on mock.
@liamsi , I have update PR with additional test and benchmark.

@vgonkivs vgonkivs requested a review from liamsi December 20, 2021 21:16
vgonkivs added a commit to vgonkivs/celestia-node that referenced this pull request Dec 20, 2021
service/share/share.go Outdated Show resolved Hide resolved
service/share/share.go Outdated Show resolved Hide resolved
service/share/share.go Show resolved Hide resolved
Wondertan
Wondertan previously approved these changes Dec 28, 2021
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@adlerjohn
Copy link
Member

Waiting on review from @liamsi

service/share/share.go Show resolved Hide resolved
service/share/share_test.go Show resolved Hide resolved
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much for this @vgonkivs

The tests are failing on a flakey test, which we have documented here: #173

@Wondertan
Copy link
Member

@liamsi required for the merged

Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you @vgonkivs 🙏🏼

Also thanks @renaynay and @Wondertan for the reviews.

@Wondertan Wondertan merged commit 9b3a304 into celestiaorg:main Jan 6, 2022
March 2022 Testnet [ DEPRECATED IN FAVOUR OF BETA ] automation moved this from In review to Finished in this sprint Jan 6, 2022
@vgonkivs vgonkivs deleted the share_implement_parallelism branch June 6, 2022 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:shares Shares and samples
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

service/share: Implement parallelisation for GetSharesByNamespace
5 participants