TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Binary search is a pathological case for caches

80 pointsby kinetikalmost 13 years ago

2 comments

brooksbpalmost 13 years ago
Here's a fun and relevant paper:<p>A Comparison of Cache Aware and Cache Oblivious Static Search Trees Using Program Instrumentation<p><a href="http://www.cs.amherst.edu/~ccm/cs34/papers/ladnerbst.pdf" rel="nofollow">http://www.cs.amherst.edu/~ccm/cs34/papers/ladnerbst.pdf</a>
koverstreetalmost 13 years ago
...This is news? You've got a tight loop with a branch, and depending on which way the branch goes, you're going to touch completely different locations in memory.<p>The solution (at least for some problems) is just to lay your data out in memory better - optimal is a binary search tree in an array, like the way heaps are implemented.<p>That's what I did for bcache: <a href="http://evilpiepirate.org/git/linux-bcache.git/tree/drivers/md/bcache/bset.h#n56" rel="nofollow">http://evilpiepirate.org/git/linux-bcache.git/tree/drivers/m...</a>
评论 #4311591 未加载
评论 #4311587 未加载
评论 #4311885 未加载
评论 #4312235 未加载