Recent

Author Topic: Benchmark optimal buffer size  (Read 142 times)

LemonParty

  • Hero Member
  • *****
  • Posts: 557
Benchmark optimal buffer size
« on: July 06, 2026, 02:19:50 pm »
Here is another benchmark.
In this benchmark we observe a typical situation when processing of buffer occur. Specifically in current case we take chunk of buffer getting bitmask from it (procedure PosRangeMask, uses SIMD) then analyze this bitmask together with buffer. Our task is to extract positions and lengths of numbers in generated string. The difference is the size of buffer we test. The initial idea is that smaller buffer sizes (that fit into L1 cache) should show better performance.

Benchmark is ready for x86 and AArch64. (Linux code not tested)

In left column size of our buffer, in right column coefficient of speed (1.000x is the fastest). Also for comparison added "simple" realization of the same algorithm that don't use SIMD.
Results from Intel Core Ultra 7 258V:
Code: Pascal  [Select][+][-]
  1.   4096     1.430x
  2.   8192     1.024x
  3.  16384     1.006x
  4.  32768     1.000x
  5.  65536     1.021x
  6. 131072     1.012x
  7. Simple     2.374x
  8.  
  9.   4096     1.153x
  10.   8192     1.013x
  11.  16384     1.215x
  12.  32768     1.082x
  13.  65536     1.000x
  14. 131072     1.135x
  15. Simple     2.228x
  16.  
  17.   4096     1.360x
  18.   8192     1.052x
  19.  16384     1.021x
  20.  32768     1.000x
  21.  65536     1.106x
  22. 131072     1.293x
  23. Simple     2.413x
  24.  
  25.   4096     1.263x
  26.   8192     1.021x
  27.  16384     1.014x
  28.  32768     1.000x
  29.  65536     1.034x
  30. 131072     1.087x
  31. Simple     2.284x
  32.  
  33.   4096     1.560x
  34.   8192     1.109x
  35.  16384     1.145x
  36.  32768     1.051x
  37.  65536     1.000x
  38. 131072     1.004x
  39. Simple     2.115x
Results from Raspberry Pi 5:
Code: Pascal  [Select][+][-]
  1.   4096     1.033x
  2.   8192     1.031x
  3.  16384     1.036x
  4.  32768     1.025x
  5.  65536     1.040x
  6. 131072     1.000x
  7. Simple     1.665x
  8.  
  9.   4096     1.269x
  10.   8192     1.224x
  11.  16384     1.001x
  12.  32768     1.000x
  13.  65536     1.013x
  14. 131072     1.130x
  15. Simple     1.938x
  16.  
  17.   4096     1.015x
  18.   8192     1.009x
  19.  16384     1.020x
  20.  32768     1.000x
  21.  65536     1.096x
  22. 131072     1.125x
  23. Simple     1.632x
  24.  
  25.   4096     1.134x
  26.   8192     1.128x
  27.  16384     1.114x
  28.  32768     1.118x
  29.  65536     1.154x
  30. 131072     1.000x
  31. Simple     1.763x
  32.  
  33.   4096     1.252x
  34.   8192     1.375x
  35.  16384     1.137x
  36.  32768     1.000x
  37.  65536     1.037x
  38. 131072     1.085x
  39. Simple     2.002x

Observations:
1. On Intel best results are shown on buffer sizes 16Kb and 32Kb. This seem to be expected, because L1 cache size on Intel is 32Kb.
2. On Raspberry best results are shown on buffer sizes 32Kb and 131Kb. This is kind of unusual, because cache size on this CPU is 64Kb.
3. SIMD based code on Intel is ~2.3 times faster than simple realization.
4. SIMD based code on Raspberry is ~1.8 times faster than simple realization.

In general buffer size don't play a big role, except situation when you take very little (like 4Kb) or very large buffer.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018