Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): avoid scanning long Katakana prefixes for search snippets #48084

MergedUtkarshUsername(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/48084/headmerged by juliusmarminge View on GitHub

Problem

A thread search match after a long run of Katakana still makes the server scan backward through the run and give the whole prefix to Intl.Segmenter. The formatter only needs enough context to find a safe place to start the snippet.

Change

Recognize boundaries between Katakana block characters and the existing ASCII and Han ranges. Keep Unicode segmentation for cuts near flags and combining marks.

Scope

Follow-up to #47404. The reproduction fits under the message limit.

Verification

The regression test fails on base 6b12843cbe and passes with the fix. InstaBox passed all 42 ThreadSearch tests and check:changed with 44 tests. In Node 26, buildSearchSnippet("カ".repeat(119_000) + "needle", 119_000) returned the same snippet with three character reads instead of 118,978 and zero segmenter calls instead of one. The counts cover snippet generation.

GPT-6.2 Sol via Codex.

    1. Pushed4fb4dcd

    2. Evidence

      Before (base 7b7ca65f)After (head 4fb4dcde)
      Raw outputRaw output
      Median 0.985 ms; 118,978 reads; 1 Segmenter callMedian 0.002375 ms; 3 reads; 0 Segmenter calls
      Same snippet: …カカカカカカカカカカカカカカカカカカカカカカカカneedleSame snippet

      Driver: bench.mjs.

    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged thisdc11614

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.