softwaremill / tapir

Rapid development of self-documenting APIs
https://tapir.softwaremill.com
Apache License 2.0
1.36k stars 418 forks source link

Reduce allocation rate #3552

Closed fwbrasil closed 8 months ago

fwbrasil commented 8 months ago

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

adamw commented 8 months ago

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.

fwbrasil commented 8 months ago

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.