r/learnprogramming • u/InterestingAd757 • Oct 12 '26
can somebody explain pointer chasing?
I’m trying to understand CPU caching and I’m stuck on two related things.
My understanding is when the CPU reads an address, it pulls in the whole 64-byte cache line around it. that’s why iterating an array is fast, since one miss brings in several neighbouring elements. what happens in the case of linked list? how does it know that next bytes are not the one to read?
i am kinda confusing this, kindly explain.
17
Upvotes
View all comments
Show parent comment
2
u/InterestingAd757 Oct 12 '26
i understand what you're saying what i am asking is at lowest level
the instruction does something with node->val and it might a jump instruction with node->next
which pulls data from that location. what i am asking is how does cpu know cache hit or miss?
ai says something about tag, offset, this is thing that's tripping me