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
Alex Rosenberg suggests that no "STL ring-buffer" will replace the most efficient real-world ring-buffer unless it supports the following performance hack:
Let's back our particular ring_view by a span of (virtual) memory exactly 2 pages[1] in length. But, in the page table, we map both of these virtual pages to the same 1 page of physical memory. This means that if you manage the head and tail pointers correctly, you can arrange it so that it is always true (in the virtual-memory space) that begin < end, which means that iterating over the ring-buffer from begin to end (or vice versa) never requires a % capacity operation.
Obviously this can't be the default behavior; but ring_view must be generic enough to support this particular idiom, or else nobody who uses this idiom will be able to switch to ring_view, which defeats the whole purpose.
How can we genericize out the % capacity part of this code so that you don't get it when it's not needed?
( [1] Well, I think 2N pages backed by N pages of physical memory would work for any N. But 2-by-1 is the easy-to-visualize case.)
The text was updated successfully, but these errors were encountered:
Alex Rosenberg suggests that no "STL ring-buffer" will replace the most efficient real-world ring-buffer unless it supports the following performance hack:
Let's back our particular
ring_view
by a span of (virtual) memory exactly 2 pages[1] in length. But, in the page table, we map both of these virtual pages to the same 1 page of physical memory. This means that if you manage the head and tail pointers correctly, you can arrange it so that it is always true (in the virtual-memory space) thatbegin < end
, which means that iterating over the ring-buffer from begin to end (or vice versa) never requires a% capacity
operation.Obviously this can't be the default behavior; but
ring_view
must be generic enough to support this particular idiom, or else nobody who uses this idiom will be able to switch toring_view
, which defeats the whole purpose.How can we genericize out the
% capacity
part of this code so that you don't get it when it's not needed?( [1] Well, I think 2N pages backed by N pages of physical memory would work for any N. But 2-by-1 is the easy-to-visualize case.)
The text was updated successfully, but these errors were encountered: