c9s / r3

libr3 is a high-performance path dispatching library. It compiles your route paths into a prefix tree (trie). By using the constructed prefix trie in the start-up time, you may dispatch your routes with efficiency
http://c9s.github.com/r3/bench.html
MIT License
813 stars 83 forks source link

Remove fixed alignment #145

Closed bjosv closed 2 years ago

bjosv commented 2 years ago

When building and running tests using an undefined behavior sanitizer it complains about misaligned member access (log). (The flag -fno-sanitize-recover=all is important here to make sure a testcase fails when found..)

Some structs are set to have 64 byte alignment, but when they are allocated this is disregarded and gives above errors. This PR removed the fixed alignment and let the compiler handle it.

Using pahole the size of the structs changes: Struct Old size New size
R3Node /_node 128 80
R3Edge /_edge 64 32
R3Route / _R3Route 128 128
match_entry / _R3Entry 128 104

Running ./run-benchmark gives equivalent results before and after this PR.

c9s commented 2 years ago

This is awesome! thanks!