pekko icon indicating copy to clipboard operation
pekko copied to clipboard

Revisit indexOfSlice performance improvements

Open pjfanning opened this issue 4 months ago • 1 comments

https://github.com/apache/pekko/pull/2306#pullrequestreview-3352698604

PR2306 already improves performance quite a bit.

There is a suggestion that we could eke out some more perf gains by using the https://en.wikipedia.org/wiki/Two-way_string-matching_algorithm - see the link above - basically trying to port Netty's code

pjfanning avatar Oct 18 '25 07:10 pjfanning

I ran the new benchmarks from #2325 against the main branch, PR2324 and PR2323 code. So far, PR2323 helps a little but PR2324 has poor performance - possibly a bug in my code that damages the performance.

indexOfSlice

Scala 2.13 main branch (Java 17.0.16)
[info] Benchmark                                            Mode  Cnt         Score         Error  Units
[info] ByteString_indexOfSlice_Benchmark.bs_indexOfSlice   thrpt    3  32742448.312 ± 7405884.505  ops/s
[info] ByteString_indexOfSlice_Benchmark.bss_indexOfSlice  thrpt    3   3944861.418 ± 1012500.206  ops/s


Scala 2.13 full 2 way impl (Java 17.0.16)
[info] Benchmark                                            Mode  Cnt        Score         Error  Units
[info] ByteString_indexOfSlice_Benchmark.bs_indexOfSlice   thrpt    3  3243337.351 ± 1006365.481  ops/s
[info] ByteString_indexOfSlice_Benchmark.bss_indexOfSlice  thrpt    3  3045235.141 ± 5055886.316  ops/s


Scala 2.13 with just getLong changes (Java 17.0.16)
[info] Benchmark                                            Mode  Cnt         Score         Error  Units
[info] ByteString_indexOfSlice_Benchmark.bs_indexOfSlice   thrpt    3  35207523.319 ± 9632183.164  ops/s
[info] ByteString_indexOfSlice_Benchmark.bss_indexOfSlice  thrpt    3   3583970.019 ±   34365.425  ops/s

pjfanning avatar Oct 18 '25 17:10 pjfanning