Repository navigation
Make LeafNode aligned to memory pages. - #2348
Conversation
cb0ba0b to
1eef691
Compare
candidate_cache is removed because of failing test make util-tests && ./unit_tests/util-tests --run_test=*/construct_multiple_levels_test first bad commit: [9692be6] Add cache for CandidateSegments to reduce heap worke even more Now SegmentIndex contains leaf index, object index and fixed_projected_coordinate
| LeafNode() : object_count(0), objects() {} | ||
| uint32_t object_count; | ||
| std::array<EdgeDataT, LEAF_NODE_SIZE> objects; | ||
| unsigned char __alignment[LEAF_PAGE_SIZE - sizeof(uint32_t) - sizeof(EdgeDataT) * LEAF_NODE_SIZE]; |
There was a problem hiding this comment.
Could you change the naming for __alignment. Symbols starting with _ _ are reserved for the stdlib implementation and I feel like "alignment" is generic enough that there is the probability for a clash somewhere somehow.
There was a problem hiding this comment.
Ok, I will change to leaf_page_padding
|
👍 Good idea, it makes a lot more sense to give the actual page size. Would be great if you could clarify some of the changes I commented on. |
Changes: * LeafNode is aligned to LEAF_PAGE_SIZE. Alignment brings 24 bytes memory overhead for 4096, but reduces cache misses rate. * Unused m_element_count from leaf nodes file. The size is computed as m_leaves_region.size() / LEAF_PAGE_SIZE. * Added try/catch for mmap exceptions messages.
|
Great work. Merged it in my branch so I can rebase on |
|
I just stumbled upon this again and was wondering if we simply can use instead of manually computing the padding. Probably less error prone and shows intent. |
|
Great! alignas can be used http://coliru.stacked-crooked.com/a/cec372d2baf66735 to avoid explicit padding, but with 64 or 128 alignment. |
References: - Project-OSRM#2348 (comment) - http://stackoverflow.com/questions/15523537/alignas-specifier-vs-attribute-aligned-c11 - http://stackoverflow.com/questions/7895869/cross-platform-alignx-macro
References: - Project-OSRM#2348 (comment) - http://stackoverflow.com/questions/15523537/alignas-specifier-vs-attribute-aligned-c11 - http://stackoverflow.com/questions/7895869/cross-platform-alignx-macro
Hi, i would like to propose the following PR
Alignment brings 24 bytes memory overhead for 4096, but reduces
cache misses rate. It will not be seen on small benchmarks, but for large memory consumptions it will be require less systems works to drop least recently used pages.
The size is computed as m_leaves_region.size() / LEAF_PAGE_SIZE.
Exceptions will cover non-existing and empty files, but also permissions, memory errors etc