-
Notifications
You must be signed in to change notification settings - Fork 115
Chore: TODO #5049
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
Chore: TODO #5049
Conversation
extend impls for BufferMutextend impls for BufferMut
8d2f9f9 to
e04bb7f
Compare
| // we know that `add` will not overflow. | ||
| unsafe { dst = dst.add(1) }; | ||
| }); | ||
| // TODO(joe): replace with ptr_sub when stable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was renamed to offset_from_unsigned
Benchmarks: Random AccessSummary
|
CodSpeed Performance ReportMerging #5049 will degrade performances by 20.36%Comparing Summary
Benchmarks breakdown
Footnotes |
Codecov Report❌ Patch coverage is
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Benchmarks: TPC-H SF=1 on NVMESummary
Detailed Results Table
|
Benchmarks: FineWeb NVMeSummary
Detailed Results Table
|
Benchmarks: FineWeb S3Summary
Detailed Results Table
|
Benchmarks: TPC-H SF=1 on S3Summary
Detailed Results Table
|
Benchmarks: TPC-H SF=10 on NVMESummary
Detailed Results Table
|
Benchmarks: TPC-DS SF=1 on NVMESummary
Detailed Results Table
|
Benchmarks: GitHub Archive (NVMe)Summary
Detailed Results Table
|
Benchmarks: CompressionSummary
Detailed Results Table
|
Benchmarks: GitHub Archive (S3)Summary
Detailed Results Table
|
Benchmarks: TPC-H SF=10 on S3Summary
Detailed Results Table
|
Benchmarks: Clickbench on NVMESummary
Detailed Results Table
|
Benchmarks: Statistical and Population GeneticsSummary
Detailed Results Table
|
e04bb7f to
0246ae0
Compare
|
Actually I'm realizing this is kind of stupid. We might as well just case on if we have an upper bound in the normal Edit: nvm Rust does not guarantee those hints are correct |
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
0246ae0 to
052df43
Compare
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
It incorrectly assumed that the upper bound for iterators is true. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2d950f1 to
dbe1155
Compare
|
We need to be careful. We build on stable compiler, which means that we don't get See #3881 for the PR that added our own TrustedLen and the |
gatesn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, your unsafe functions should have more debug_asserts. e.g. set_len
| let bit_in_byte = bit_pos % 8; | ||
|
|
||
| // Ensure buffer has enough bytes | ||
| // Ensure buffer has enough bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, no
| // Bit is already 0 if we just pushed a new byte, otherwise ensure it's unset | ||
| // Bit is already 0 if we just pushed a new byte, otherwise ensure it's unset. | ||
| if bit_in_byte != 0 { | ||
| self.buffer.as_mut_slice()[byte_pos] &= !(1 << bit_in_byte); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use crate::bit::set_bit instead
| } | ||
|
|
||
| // Set the bit. | ||
| self.buffer.as_mut_slice()[byte_pos] |= 1 << bit_in_byte; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use the set function
| let byte_pos = bit_pos / 8; | ||
| let bit_in_byte = bit_pos % 8; | ||
|
|
||
| // Ensure buffer has enough bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the caller asserted this already. So this statement should never be true, i.e. you can delete it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the semantics of with_capacity though? Tracing through I can't figure out the answer to this question: are all bytes guaranteed to be zeroed? If not then I think we might need to do this
| let bit_in_byte = bit_pos % 8; | ||
|
|
||
| // Ensure buffer has enough bytes. | ||
| if byte_pos >= self.buffer.len() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, delete it
| unsafe { dst.write(item) }; | ||
|
|
||
| // Note: We used to have `dst.add(iteration).write(item)`, here. However this was much | ||
| // slower than just incrementing `dst`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it really slower? Still doing one addition per loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, that comment was there before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was weirdly slower, somehow it was not optimised to the same thing
|
@a10y even with the trick we employ here? Basically reserve the lower bound of items, then consume the iterator up to the known capacity, after which, we loop over items using checked appends. Seems like if the iterator was emitting a correct bound, then we'd never hit the slower loop portion? My understanding of the min-specialization uses is that e.g. extend(slice::iter) can be implemented using a memcpy, since we can specialize and know that the iterator is just backed by a slice. |
Deploying vortex-bench with
|
| Latest commit: |
052df43
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0b5a9292.vortex-93b.pages.dev |
| Branch Preview URL: | https://ct-clean-extend.vortex-93b.pages.dev |
I got tripped up when reading this and misunderstood how this worked so I just decided to clean it up
Edit: now this PR is also going to attempt to remove
TrustedLeniterator