perf(wamrc): Replace slow symbol lookup with hash map in wamrc#4912
perf(wamrc): Replace slow symbol lookup with hash map in wamrc#4912jammar1 wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
…ion/emission The relocation symbol deduplication in aot_emit_aot_file.c used a linked list, requiring O(n) traversal per relocation to check for duplicates. Replace with a lazily-allocated hash map for O(1) lookups. The linked list is preserved for ordered iteration during emission.
lum1n0us
left a comment
There was a problem hiding this comment.
Thanks for the optimization! The performance improvement is meaningful.
However, I have a question about the design: currently, when a new symbol is not found, the code creates both an AOTSymbolNode (for the linked list) and an AOTSymbolHashEntry (for the hash table). This means two separate allocations storing the same symbol and index.
Is there a specific reason to keep the linked list if the hash table already provides O(1) lookup? The linked list seems to only be used for ordered iteration during destruction, which could also be done by iterating the hash table buckets?
|
We do currently use the list for symbol emission too, in |
Replace slow symbol lookup with hash map in AOT compilation.
The relocation symbol deduplication in aot_emit_aot_file.c used a linked list, requiring O(n) traversal per relocation to check for duplicates.
Replace with a lazily-allocated hash map for O(1) lookups. The linked list is preserved for ordered iteration during emission.
When testing against a fairly large Wasm binary (about 18MB) this reduced compilation time by about ~15%.