The two-pointer merge that never reached the chart file
One page took ten seconds to render. The fix was already written, commented and shipped in a sibling file.
The worst ticker page took 10.7 seconds, and the temptation was to read the code
first. Measuring first said something more useful: the cost was server-side
rather than network, and it scaled with pool size. First hits looked slow and
repeats looked fast, which smells like a cold cache, but the timings held steady
across passes twenty-six seconds apart, well outside the fifteen-second
s-maxage.
What was left was honest work. Matching each swap to the oracle round standing
at that moment was written as rounds.reverse_each.find, once per swap. Swaps
arrive ascending and reverse_each starts from the newest round, so the early
swaps walked nearly the whole array. On a busy pool that is most of ten seconds.
A sibling file had already replaced that exact pattern with a two-pointer merge, under a comment saying that on a pool with 200k swaps and 3k rounds the difference is the page loading or not. The fix was written, measured and shipped. It just never reached the chart.
The page now renders in 2.16 seconds, and six of the ten are under 300 milliseconds. Five times better than it was, and still short of the sub-500 milliseconds I predicted.