Project-Diablo-2 / BH

A modified version of slashdiablo's BH for Project Diablo 2
GNU Affero General Public License v3.0
23 stars 23 forks source link

Prebuild substitutions for rule output #50

Open exiledagain opened 6 months ago

exiledagain commented 6 months ago

This is a ~25x average speed-up for variable substitution in the loot filter for names.

I have included commits for microbenchmark and comparison between the two results. Every 1000 rules will write results to a file called debug_new.txt and debug_old.txt as well as printing the statistics in-game.

filter version min max avg (ms)
PiLLLaaHypeS9 old 0.0547 1.3201 0.11455
PiLLLaaHypeS9 new 0.0014 0.3321 0.00428
kassahi old 0.0508 2.2842 0.107294
kassahi new 0.0013 0.3933 0.003851
Hiim old 0.0495 1.8932 0.101137
Hiim new 0.0012 0.318 0.003772
Kryszard old 0.0509 1.848 0.106611
Kryszard new 0.0013 0.3486 0.003975
eqN old 0.0521 2.4467 0.114723
eqN new 0.0015 0.2658 0.003855
exiledagain commented 5 months ago

When I ran a replacement benchmark previously, the peak timing was very small. After testing more, the timings can be quite high. The Visual Studio profiler showed that most time was spent in creating the regex and searching for the matches. Simply putting a static initialized variable and making the regex static was only ~5-6x slower than this patch.

Refactored solution similar timing: filter method min max avg (ms)
kassahi meme hype old 0.0498 4.2516 0.112722
kassahi meme hype new 0.0012 0.4384 0.003889
eqN old 0.0513 1.4403 0.103337
eqN new 0.0012 0.3343 0.004782
PiLLLaa hype s9 old 0.0531 7.4987 0.126096
PiLLLaa hype s9 new 0.0012 1.6199 0.005543
Hiim old 0.0465 2.5609 0.105658
Hiim new 0.0008 0.3365 0.003631
Kryszard old 0.0488 9.8758 0.113132
Kryszard new 0.0012 0.3629 0.004542
Canite commented 2 months ago

I'll review this before the next upcoming season

exiledagain commented 4 days ago

Removed COLOR_REPLACEMENTS as it was no longer used, fixed merged conflicts around nlAllowed, and added transparency colors. I don't think I have the right gfx version so I didn't see any transparent text, but the filters gave the same output.

Canite commented 3 days ago

Removed COLOR_REPLACEMENTS as it was no longer used, fixed merged conflicts around nlAllowed, and added transparency colors. I don't think I have the right gfx version so I didn't see any transparent text, but the filters gave the same output.

The transparency options require the latest compiled version of the pd2 d2gl branch as well.