adhocteam / pushup

Pushup is for making modern, page-oriented web apps in Go
https://pushup.adhoc.dev
MIT License
840 stars 30 forks source link

Performance optimizations re: network thresholds #45

Open dvogel opened 1 year ago

dvogel commented 1 year ago

There's different thresholds that avoid extra network latency increments:

For each of these thresholds, time-to-first-byte could be optimized by flushing the output buffer at the threshold. However time-to-last-byte could be penalized if the full output would have come in under the next threshold anyway.

e.g. if you have a 63k page and you flush after 1500 bytes you'll end up sending two IP packets instead of 1 and the page won't be fully available until the second IP packet arrives whereas without the 1500 byte flush you would not be able to parse as early but you'd probably finish parsing earlier since there would be no need to ACK the first IP packet.

The generated code could be instrumented by the compiler to maintain heuristics for the size of each page. Any pages that usually surpass a threshold could have their output buffer flushed at the lowest threshold to optimize for TTFB.

(caveat: the time-to-last-byte penalty may not matter for HTTP/3 which uses UDP and thus no ACK)