Skip to content

Conversation

@Kerollmops
Copy link
Owner

No description provided.

Comment on lines 106 to +107
let reference = unsafe { s.get_unchecked(mid) };
yield prefetch(reference);
yield mid;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you doing a s.get_unchecked(mid) before yielding mid to be prefetched by the kernel ? wouldn't this touch the memory twice ?

[edit]: I tried timing the in_memory benchmark swapping the order of yield mid with let reference = .. and it was a lot slower contrary to my expectations 🧐 why is this the case?

Copy link
Owner Author

@Kerollmops Kerollmops Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What get_unchecked is just an offset on top of a pointer, giving you a reference. I return mid to be prefetched later and the reference is dereferenced (read) just after the yield. The memory access (load of page) is done when we dereferenced to read the value. I don't know exactly why inverting the yield and get_reference is slower though 🤔

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

Successfully merging this pull request may close these issues.

2 participants