You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduced 'MACROS_MAP' to replace the original 'MACROS' structure,
and refactored related logic with hashmap utilities.
To make this change improves memory flexibility and
future extensibility, I set 'MAX_ALIASES' to 128.
The original value (1024) is excessive, as uftrace analysis
shows that the number of aliases rarely exceeds 64
in practice(measured via 'uftrace record ./out/shecc ./src/main.c'),
and the total number of '#defines' in 'shecc' is typically below 70.
In shecc's hashmap implementation, a rehash is triggered when
the number of entries exceeds 75% of the capacity.
With this load factor of 0.75, a capacity of 128 supports up to 96
entries before rehashing, which comfortably covers observed
usage while providing sufficient headroom.
In contrast, a capacity of 64 only allows 48 entries, increasing
the likelihood of rehashing.
uftrace confirms this: setting 'MAX_ALIASES' to 64 triggered one
more 'hashmap_rehash' compared to 128.
Therefore, I chose 128 over 64 to avoid unnecessary rehashing while
still keeping memory usage significantly lower than
the original default.
0 commit comments