Skip to content
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

Support physical memory hack ("magic ring buffer") #2

Open
Quuxplusone opened this issue Oct 22, 2015 · 1 comment
Open

Support physical memory hack ("magic ring buffer") #2

Quuxplusone opened this issue Oct 22, 2015 · 1 comment

Comments

@Quuxplusone
Copy link
Owner

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.)

@Quuxplusone
Copy link
Owner Author

@Quuxplusone Quuxplusone changed the title Support physical memory hack Support physical memory hack ("magic ring buffer") Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant