-
Notifications
You must be signed in to change notification settings - Fork 397
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
Copy Avoidance #355
Comments
I wonder if it's feasible to use iterator_traits::reference instead of value_type here: |
Hi! rxcpp attempts to ensure minimal copies. Bugs fixes for excessive copies are welcome! In this case, rxcpp is async by default. this means that the vector copy would be avoided by passing a non-owning range to
I think that the per value copy could be removed using Thanks! |
Thanks for the suggestion.
speeds up things quite a bit by using range-v3. I would like to be able to write:
But the code doesn't compile. Is there a way to make a range-v3 view a source for rxcpp::observable without forcing a copy to a vector followed by iterate()? I suspect a new source would've to be written. Re: PR for const_reference I wrote some code along the following lines, but it didn't quite work. I suspect more extensive changes are needed. |
Hi, rxcpp is not a replacement for range-v3. if the data is already in a vector, then range-v3 is the right tool. if the values are arriving later, then rxcpp is the right tool. The changes for const ref: looks like iterate_traits::reference was defined and then iterate_traits::const_reference was referenced. I would expect this to work:
What was the error? |
The reason why I'll take another look at isolating the const_ref changes to on_next. Thanks! |
Forgot to add the actual error message:
|
it looks like there is an errant & in the type of the iterator. perhaps you could try this edit in rx-iterate.hpp and see if that fixes it?
|
That change does fix it. Thanks! Re: Using range-v3 for vectors and rxcpp for streaming Things get a bit complicated when a common optimization called "microbatching" is applied. The idea is to delay processing for efficiency. It'd be great if the end user writing the logic doesn't have to worry about the optimizations the stream processing system is performing under the covers. One way this could be handled is to pass a vector to on_next() by const reference. |
are you referring to the buffer operators? |
ReactiveX#355 reported that range-v3 ranges failed due to an errant `&` in the `iterator_type`
#355 reported that range-v3 ranges failed due to an errant `&` in the `iterator_type`
Yes. Glad to know rxcpp already takes care of it. I was looking into the implementation here: and was wondering if we can avoid the copy in deque/chunks. One technique iterlib uses for these types of things is to use pointers. Example usage: https://github.com/facebookincubator/iterlib/blob/master/include/iterlib/OrderByIterator.h#L89 But in order for this to work, the underlying container has to ensure that the pointer remains valid until the item is consumed. https://github.com/facebookincubator/iterlib/blob/master/include/iterlib/RocksDBIterator.h#L52-L60 Thanks for looking into this and merging the fix. |
Hi! I am finally back after a trip.
When the time or count windows are overlapping the copies are required (the same value is part of multiple vectors). I think your best solution would be a new set of operators - views of a views on a deque would have to be deep copied to a vector if they needed to retained after the stack unwound to the Another approach would be for the IO case. making a buffer pool with an owning reference type or a copy-on-write buffer type would allow chunks of data to be efficiently passed by value (copy or move) through all the rxcpp operators. |
After digging into the micro benchmark linked here:
facebookarchive/iterlib#25
and looking at some profiles, I suspect that there is a copy going on between the observable -> skip -> take. Is there a way to avoid the copy in this code?
The text was updated successfully, but these errors were encountered: