diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.08k stars 794 forks source link

Optimize `DoCrawl` #7317

Closed glebm closed 3 months ago

glebm commented 3 months ago

10x faster for radius 20.

Benchmark:

cmake -S. -Bbuild-reld -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON
cmake --build build-reld --target crawl_benchmark && build-reld/crawl_benchmark

Before:

------------------------------------------------------
Benchmark            Time             CPU   Iterations
------------------------------------------------------
BM_Crawl/1        3.53 ns         3.53 ns    198384032
BM_Crawl/4        54.3 ns         54.2 ns     12907171
BM_Crawl/16        733 ns          732 ns       955101
BM_Crawl/20       1142 ns         1141 ns       613766

After:

------------------------------------------------------
Benchmark            Time             CPU   Iterations
------------------------------------------------------
BM_Crawl/1        1.36 ns         1.36 ns    453018506
BM_Crawl/4        5.59 ns         5.59 ns    124244505
BM_Crawl/16        102 ns          101 ns      6577269
BM_Crawl/20        147 ns          147 ns      4684004