softwaremill / tapir

Rapid development of self-documenting APIs

Home Page:https://tapir.softwaremill.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduce allocation rate

fwbrasil opened this issue · comments

Tapir version: 1.8.4

Scala version: 3.3.1

Describe the bug

I'm using Tapir to join a performance benchmark challenge with Kyo. The implementation is highly optimized so Tapir's object allocation overhead became the main bottleneck. This is likely relevant only for high-throughput and very lightweight endpoints but reducing the allocation rate would help better position Tapir and kyo-tapir in similar benchmarks.

How to reproduce?

Clone https://github.com/fwbrasil/rinha-2024-q1 and https://github.com/zanfranceschi/rinha-de-backend-2024-q1. Run ./run.sh and then ./executar-teste-local.sh on the respective repositories.

Additional information

  • I'm planning to submit multiple PRs to the different repositories that Tapir uses and link them to this ticket.
  • The challenge deadline is March 10, so it would be great if there are artifacts with the optimizations by then but I can also publish snapshots locally instead.
  • I'm planning to move fast without microbenchmarks for validation but let me know if you'd prefer a more structured approach. I can try introducing JMH benchmarks for the changes.

Thanks! Looks promising :)

I don't think microbenchmarks would be necessary, they wouldn't likely spot regressions - which would appear in new places. @kciesielski is currently working on a testsuite which we could run periodically to verify if performance hasn't degraded - so while its general resolution might not be as high, I think it should be enough for now to ensure that we aren't dramatically worse in performance.

As for the changes, we'll mostly review / merge / release from Monday, as tomorrow we're out of office until Sunday.

Thank you so much for the quick reviews and the release with the changes! I think I benefited of other optimizations in the latest release as well and I'm happy with the performance of Tapir in my benchmark now :) I'm closing this issue since I'm not planning to work on more allocation-related optimizations for now.