You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the flow API's spsc_buffer<T> I can specify a capacity in terms of number of elements. In my application, I want to limit the buffer's memory usage. This can easily be implemented when all instances of T use the same amount of memory. However, as soon as instances of T vary in their memory usage, I can no longer restrict the buffer's memory usage.
The spsc_buffer is just one concrete example that I'm using to explain the problem, but I think this should have a much more general solution in CAF, as the ability to restrict a buffer's memory usage is mission-critical to many types of applications.
Instead of using the size of the internal buffers as an upper bound, I propose calculating the sum of the weights of all elements in the internal buffers, using that as an upper bound. This weight should default to 1, and have its own customization point.
Constantly recalculating the total weight may be very expensive, so the sum should likely be cached and updated whenever an element is added to or removed from the the buffer, ensuring that the weight customization point is called at most twice per element and buffer.
The text was updated successfully, but these errors were encountered:
In the flow API's
spsc_buffer<T>
I can specify a capacity in terms of number of elements. In my application, I want to limit the buffer's memory usage. This can easily be implemented when all instances ofT
use the same amount of memory. However, as soon as instances ofT
vary in their memory usage, I can no longer restrict the buffer's memory usage.The
spsc_buffer
is just one concrete example that I'm using to explain the problem, but I think this should have a much more general solution in CAF, as the ability to restrict a buffer's memory usage is mission-critical to many types of applications.Instead of using the size of the internal buffers as an upper bound, I propose calculating the sum of the weights of all elements in the internal buffers, using that as an upper bound. This weight should default to 1, and have its own customization point.
Constantly recalculating the total weight may be very expensive, so the sum should likely be cached and updated whenever an element is added to or removed from the the buffer, ensuring that the weight customization point is called at most twice per element and buffer.
The text was updated successfully, but these errors were encountered: