ox icon indicating copy to clipboard operation
ox copied to clipboard

Cancelling `CancellableFork` optimization

Open micossow opened this issue 1 year ago • 0 comments

Benchmarking the new groupedWithin operator showed that cancelling CancellableFork that hasn't started yet can be optimized. CancellableFork.cancelNow creates InterruptedException. I replaced that exception with no-stack-trace variant and observed an improvement.

Benchmark code:

supervised {
  for (i <- 1 to 15) {
    val c = Source.range(1, 1000000, 1)
    val start = System.nanoTime()
    c.groupedWithin(3, 1.second).drain()
    val dur = System.nanoTime() - start
    println(dur / 1000000)
  }

Results (median):

  • current solution: 2627 ms
  • no-stack-trace variant: 1261 ms

micossow avatar Jun 26 '24 06:06 micossow