Skip to content
Discussion options

You must be logged in to vote

Because get_batch selects a random start position (pos_dist(thread_rng)), the CPU suddenly requests a memory address that the OS hasn't loaded into RAM yet. This causes a page fault, forcing the thread to freeze and wait for the physical hard drive to fetch the data. Using a memory advice hint (like madvise(MADV_SEQUENTIAL) or madvise(MADV_WILLNEED), though not currently in the code) tells the OS to aggressively pre-load the upcoming pages in the background, eliminating the freeze.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eamonsippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants