docs/solutions/developer-experience/2026-05-08-slate-benchmark-percentile-slices-must-repair-one-current-caller.md
Performance planning needed p75/p95/p99 in repeated-sample artifacts before any threshold could be honest. Adding the shared summary fields was not enough, because several benchmark callers had drifted behind the current Slate write API and could not produce artifacts.
bench:core:editor-store:local failed on Editor.setChildren.Editor.withTransaction, editor.insertText, and editor.select.Keep the shared helper change small, then repair one current core caller enough to prove the schema.
In scripts/benchmarks/shared/stats.mjs and
scripts/benchmarks/shared/react-benchmark.tsx, add one percentile helper and
emit additive fields:
const percentile = (sorted: number[], ratio: number) => {
if (sorted.length === 0) return 0
const index = Math.min(
sorted.length - 1,
Math.max(0, Math.ceil(sorted.length * ratio) - 1)
)
return sorted[index]
}
Then include:
p75: round(percentile(sorted, 0.75)),
p95: round(percentile(sorted, 0.95)),
p99: round(percentile(sorted, 0.99)),
For the core proof caller, update editor-store.mjs to the current API:
editor.update((tx) => {
tx.text.insert(text, options)
})
Use internal state helpers only where the benchmark is intentionally measuring low-level state mechanics:
import { Editor, setEditorChildren } from '../../../../packages/slate/src/internal/index.ts'
setEditorChildren(editor, createChildren(blockCount, `children-${index}`))
const children = Editor.getSnapshot(editor).children
Proof commands:
bun run bench:core:editor-store:local
bun run bench:react:huge-document-overlays:local
bun check
Inspect the emitted JSON artifacts, not just command success:
.tmp/slate-editor-store-benchmark.jsonpackages/slate-react/tmp/slate-react-huge-document-overlays-benchmark.jsonThe shared helpers carry the artifact schema for many benchmark families. One core artifact and one React artifact prove both helper paths without migrating the whole benchmark suite.
Repairing exactly one stale core caller preserves slice boundaries: percentile artifact shape is done, while broader benchmark API drift remains a separate bounded owner.