-
Notifications
You must be signed in to change notification settings - Fork 21
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
Poor performance of SliceDeque::<u8>::truncate_front() #69
Comments
@dvtomas thank you for the report. In general, without something like #33, allocating and re-allocating deques (e.g. due to growing) is currently expected to be very slow - probably the slowest part of the API right now (help with #33 would be appreciated). However, First question: do you have a significantly simpler reproducer ? For example, what's the performance of |
So I have modified the |
Just tried that, looks perfect. Both on Linux and Windows the |
So I've released a new The fix was to just dispatch to the drop method of the sub-slice |
I'm using SliceDeque as a queue for incoming binary data (u8) from network. In a loop packets arrive and line up in the queue (
extend
), I parse the data from the packets, andtruncate_from
the relevant portion of the SliceDeque. It works very nice in theory, but in practice, I've found outtruncate_front
is slow on Linux, and really sluggish on Windows.I've created the following simple benchmark app: https://github.com/dvtomas/rust-slicedeque-bench.
Basically, it creates a SliceDeque, and repeatedly
extend()
s it, andtruncate_front()
s it. The number of items to extend and to truncate in each call is slowly increasing by a configurable amount. All this can be run in multiple threads, but the performance can be easily seen even from single thread run.Here is a log excerpt from a run on my Linux box:
The columns are:
You can see that on Linux, the time to truncate is roughly 10x longer than the time to extend. That's not good, but not horrible. Now let's look at a Windows run with the same parameters:
(The whole log from a run on my friend's Windows computer can be seen here: https://gist.github.com/dvtomas/2968240b9c9be2ca11dcee63dc5abe60)
It takes 174 us to grow a 2MB queue by ~90kb, but 363 ms to remove ~90kb from the front!
This kind of performance makes SliceDeque impractical for my purposes. Is there anything wrong with the way I'm using it? Is this something that could be solved?
The text was updated successfully, but these errors were encountered: