Poor man's work stealing queue (30%-60% improvement depending on number of cores)#5
Open
cmlsharp wants to merge 5 commits intojonhoo:mainfrom
Open
Poor man's work stealing queue (30%-60% improvement depending on number of cores)#5cmlsharp wants to merge 5 commits intojonhoo:mainfrom
cmlsharp wants to merge 5 commits intojonhoo:mainfrom
Conversation
Replace semi_at and next_newline with a simpler (and seemingly significantly faster) simd search. I define a `find_byte` function which is generic over the number of SIMD lanes. I then select lane sizes for the newline and semicolon searches that minimize total time (on my machine anyway) which wound up being significantly smaller than the previous choice of 64. I suspect this is because newlines and (especially) semicolons are often found relatively early and using a smaller number of lanes improves latency (at the hypothetical cost of throughput). This also removes the need for `memchr` (calling it on the slow path yields no discernable difference).
c5ca651 to
233587d
Compare
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 is adapted from my own solution to this challenge. It builds atop #2 . I would have preferred to keep PRs independent, but the efficiency of this change requires newline searching to be faster.
It makes the following changes:
pread(viaread_at_exact) but this was marginally slower.The speedup here seems to depend heavily on the number of cores. On a very powerful machine with 128 logical cores, this yielded a 60% improvement relative to #2. When limiting to 8 cores, it was closer to a 30% improvement on that same machine.
It would be interesting to fully disambiguate what fraction of this improvement is from the "AtomicU64" change and which is from the "fixed sized reads of 64KB" vs memory mapping. I did try a version of this approach with memory mapping as mentioned above and it was slower, but I do not remember by how much.