-
Notifications
You must be signed in to change notification settings - Fork 9
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
SPSC memory is allocated twice #74
Comments
Your analysis is correct, and this behavior is intended. I agree it's kind of ugly. For
I'm happy to hear that! I'm a big fan of rtrb's interface, and if you merge that I'll be out of excuses not to pull it in directly in favor of my reinvented wheel here. |
Thanks for confirming my speculations!
Yeah, that's definitely an advantage. My implementation has quite a lot of
Well, that's the question, I'm not sure about that. In general, yes, I care more about the real-time operation than the initialization phase. Also, I have an idea to push this even further (but I don't know whether it's a good idea!): One could provide an (unsafe) API to construct a
In fact, I can get away with a much simpler approach than actual refcounting.
Yeah, I'm still unsure, I'd like to gather more input before moving forward. However, I've already found a few places where the Rust compiler doesn't seem to optimize away all abstractions, so I had to "lower" a few of them to get competitive performance, see mgeier/rtrb@d0764ba. Have you experienced clear performance improvements when switching to a DST? Apart from performance, I think it's more elegant to have I'd be happy about any kind of input! |
This is probably not a big deal, I just wanted to mention it because it surprised me when I first realized it ...
oddio/src/spsc.rs
Lines 197 to 202 in adc60db
After allocating all memory, the
Box
is converted to anArc
which allocates completely new memory and copies the initialized values to it. AFAICT, the originally allocated memory is deallocated again at the end of thenew()
method.Is this intentional?
Or am I missing something?
I found this when trying to convert my own SPSC ring buffer to a DST (see mgeier/rtrb#75), where this crate's code was very helpful. I avoided the repeated allocation by manually implementing a small subset of
Arc
for this special case instead of usingArc
directly.The text was updated successfully, but these errors were encountered: