Use multiple linked lists to reduce contention in the segment pool#727
Merged
Conversation
Also round up the number of cores to the nearest power of two. Also change the behavior of SegmentPool.byteCount to only track the parts of the pool accessible to the current caller. This builds upon rewlad's fine work of tuning the segment pool.
swankjesse
commented
May 31, 2020
Collaborator
Author
swankjesse
left a comment
There was a problem hiding this comment.
I’d like to land this PR and cut an Okio release!
| actual val byteCount: Int | ||
| get() { | ||
| val first = firstRef().get() ?: return 0 | ||
| return first.limit |
Collaborator
Author
There was a problem hiding this comment.
@rewlad rather than trying to make this correct, I’m just redefining the field to only return the byte count accessible to the current thread. That’s certainly enough to make our tests happy!
Collaborator
Author
|
I benchmarked 3 segment pool implementations. I used 128 threads on my 16 core MacBook Pro. no poolingmemory: 0 KiB mastermemory: 64 KiB hash buckets (this PR)memory: 16 cores * 64 KiB = 1 MiB thread local segment poolmemory: 128 threads * 64 KiB = 8 MiB This implementation is definitely a compromise on memory vs. CPU. |
Collaborator
Author
|
Forgot to link the benchmark! |
oldergod
approved these changes
Jul 6, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a commit to @rewlad's PR 725.