]> mop.ddnsfree.com - git repositories - brisk.git/commit
the chat redrew the box one line at a time
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:37:31 +0000 (12:37 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Sun, 13 Sep 2026 10:37:31 +0000 (12:37 +0200)
commit59232fa168e3f8627ff3f49ce28af48ae7eb6e27
treee32c604bba5f255f72bf5a83490b797c245012f6
parent225e0fbe4b55801315dcb945eb6e75d5b702b1c0
the chat redrew the box one line at a time

Once the CHATT_MAXLINES ceiling was reached, every incoming message emptied
the box and then filled it line by line, assigning innerHTML on each turn.
Each += on innerHTML forces the browser to reserialise the content, reparse
it and rebuild the subtree: 41 rebuilds of the DOM per message, with a cost
that grows with the square of the number of lines.

Now the shift happens on the array and the box is rewritten once.

It came out of the load test: with 150 players chatting (15 messages a second
broadcast to everybody) a real browser saturated twelve cores and died, while
the daemon serving that traffic sat at 6% of one core. The bottleneck was the
client, not the server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014M1jiEq9cHdE5SE5j6vFuE
web/commons.js