Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Array of struct tends to only be better when there's high temporal locality of using nearly all the fields.

This code, as written, makes left node accesses temporally correlated with other left node accesses (and by symmetry must do the same for right nodes), allowing the caches at all levels to have a higher hit rate. Whether that higher rate is actually attained depends on the architecture, compiler, other running code, linker, and all sorts of other garbage, but it has a lot higher chance of better behavior anyway.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: