[Refactor] Case node efficiency boost
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch refactors some code related to jump table generation by removing some unnecessary variable initialisation and storing the lower and upper bounds of the domain (e.g. Low(Int64) and High(Int64)) so it does not have to call "getrange" multiple times. It also uses local variables for these values as much as possible in order to minimise memory fetches and cache misses (as well as increasing the chance of these values being stored in registers).
Steps to reproduce:
Compile a test program, observing the time taken, then apply patch and repeat the operation, observing the time taken and confirming that the compiled binaries are byte-for-byte identical.
Additional information:
Timings for compiling Lazarus with -B -s options. It was difficult to get consistent results on my laptop, but I've done my best with 7 iterations apiece.
Case node refactor:
[85.289] 1298541 lines compiled, 85.3 sec
[85.574] 1298541 lines compiled, 85.6 sec
[82.023] 1298541 lines compiled, 82.0 sec
[81.059] 1298541 lines compiled, 81.1 sec
[82.406] 1298541 lines compiled, 82.4 sec
[81.391] 1298541 lines compiled, 81.4 sec
[80.035] 1298541 lines compiled, 80.0 sec
Mean: 82.540
Median: 82.023
Control (Trunk)
[89.441] 1298541 lines compiled, 89.4 sec
[84.145] 1298541 lines compiled, 84.1 sec
[84.832] 1298541 lines compiled, 84.8 sec
[92.023] 1298541 lines compiled, 92.0 sec
[88.996] 1298541 lines compiled, 89.0 sec
[86.074] 1298541 lines compiled, 86.1 sec
[85.480] 1298541 lines compiled, 85.5 sec
Mean: 87.284
Median: 86.074
Mantis conversion info:
- Mantis ID: 35479
- OS: MIcrosoft Windows
- OS Build: 10 Professional
- Platform: i386 and x86_64
- Version: 3.3.1
- Monitored by: » Artem3213212 (Artem3213212)