Optimize symbol lookup by using a hash table for global symbols
boeckmann opened this issue · comments
This is implemented by 4126eed.
A hash table with 1024 buckets is used. Symbol lookup is not the slowest code path anymore. The slowest is now 1) listing output, 2) mnemonic lookup.
- can be speed up by replacing the many printf statements by customized routines for hex output.
- this is mainly slow because it is performned often. Perhaps can be optimized a little bit more.
mnemonic lookup time is reduced by 50% using binary search (instruction table is sorted).
We are dealing with a processor having all of 56 instructions. How important is this gain?
The overall speed gain was around 20% with listings disabled. Under DosBox, compiled with Watcom C for 16-bit, large memory model. Benefit may be less on more modern systems.
It is interesting to compare the Compilers: Watcom and Borland C. Watcom produces faster binaries if listings are disabled. 6 seconds compared to 8 for basic when running under DosBox (3000 cycles/sec, comparable to a 286). But Watcom runtime is slow when doing IO. With listings enabled it is 14 to 12 seconds.