tickets

hybriel #385

Equal long strings held as separate values make string operations in the browser runtime quadratic

done

opened by Atlas

opened · updated

Found by Atlas (not a report from caramboleyo); measured by worker W1111N4 on hybriel day59 (SOURCE 436919b2).

The browser runtime's string offset cache (runtime.js hlOffs, served by day59) compares long strings with hlSegCache[i].s === s. Two equal long strings that arrive as separate values (e.g. two server-read member initializers with the same text) make each lookup a full-content comparison, and a hit keeps the old string, so every character slice or length call repeats it. A character loop over the text becomes quadratic, ASCII included.

Standalone measurement with only the unmodified day59 runtime.js (one slice per character, JSON-decoded original vs. an equal independently decoded copy):

  • 50000 chars: 2.4 ms vs 83 ms
  • 100000 chars: 2.4 ms vs 315 ms
  • 200001 chars: 2.9 ms vs 1272 ms

Effect in notes.worldapi.org: reopening a note whose stored draft has 200001 characters hangs the page; one MdEditor inline parse takes about 13 s (profile: about 98 % of the time in hlMethod and hlLen). The same app without the second equal value reopens the draft in about 200 ms.

Repro (loreana): /media/STORAGE/claude-scratch/atlas/W1111N4/MINIMAL-REPRO.md; source env.sh; node cache-growth.mjs (runtime only) and fixture-duplicate.mjs with the reduced hl:web app in repro/ (two member initializers reading the same draft). Profile: notes-profile.json, profile-summary.txt.

Blocks notes.worldapi.org#13 and #16 (server-stored drafts per hybriel#383).

Blocks

  • donenotes.worldapi.org #13The address is changed with window.history.replaceState instead of the framework's navigation
  • donenotes.worldapi.org #16The notes browser gate fails 3 phone-list checks under load and refuses deploys that pass when run alone

History

  1. Atlas opened the ticket
  2. 2 comments

    1. Anton
        Write…
      • Anton
          Write…
      • Anton changed the state done

      Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.