-
Notifications
You must be signed in to change notification settings - Fork 59
Zero-Copy ReadSlice Trait #530
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
base: master
Are you sure you want to change the base?
Conversation
Dekkonot
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.
I'm a clever boy and can work out that the new functions aren't a part of RbxReadExt because they operate explicitly on a slice instead of a nebulous impl Read, but it might be worth writing it down for future generations. I'll leave that to your discretion, but I tend to err on the side of writing things down even if they feel obvious because it lowers the bus factor for the project.
Otherwise this seems fine to me.
Done. When I was writing this PR at first I was considering a trait too, but decided this was simpler. If you think you can improve the clarity of the documentation wording, suggestions or changes are welcome. |
d11943d to
cb31d0b
Compare
bec313b to
213089b
Compare
|
|
16012e0 to
ce60a46
Compare
|
|
|
The compiler keeps whispering ways to make the code better. Now I can put all the functions back into the RbxReadExt trait and use a trait bound to access the zero-copy read_slice method. It's shrunk the core.rs diff considerably. |
Co-authored-by: Micah <[email protected]>
Utilize ToOwned to copy strings when necessary.
the split_at can panic, there is a checked variant if it should be handled gracefully
This reverts commit 030f68a.
2634185 to
d637219
Compare
|
The complete vision of changes adding to this PR:
I would like to open stacked PRs, but they need to be created with a branch within the repository itself, which I don't have access to. |
If you are too keen, you can make PRs on your own fork of rbx-dom and link them. I'd probably just merge them with a squash though so you can theoretically rebase after they're merged. |
|
Hmm that sounds like two pull requests for the price of two, and without the merge target update of a stacked PR. Speaking of which, a stacked PR will only update the merge target, not automatically rebase, so maybe it's not as useful as I imagined when PRs are squashed to master. Seems like it would still need maintenance from me regardless. I'll just continue to be patient and resolve conflicts as they arise. |
This reverts commit 6b5ac80.
|
I've split out the RbxReadInterleaved change into its own PR #592. This is just the ReadSlice trait now. |
kennethloeffler
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.
Nice, this looks to be a significant optimization for light workloads: I saw about +10% on the small benchmarks. It makes sense, since we have proportionally more strings to copy in larger files. Code looks great to me, nice work!
The point of these changes is to reduce the number of copies where possible. To achieve this, we split off chunks of a byte slice instead of allocating a String or Vec where applicable.
Performance
5-8% faster on the deserialize microbenchmarks according to my testing. This mostly affects performance on a per-prop-chunk basis rather than per-property which explains why it doesn't seem to have a big impact on the Miner's Haven benchmark. This is probably also why #545 didn't see a big performance uplift.