Skip to content

[diffs/edit] Improve pieceTable performance - #1001

Merged
ije merged 3 commits into
beta-1.3from
ije/improve-piecetable-perf
Jul 17, 2026
Merged

[diffs/edit] Improve pieceTable performance#1001
ije merged 3 commits into
beta-1.3from
ije/improve-piecetable-perf

Conversation

@ije

@ije ije commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Benchmark results
p50 latency in milliseconds; two warmups and nine measured samples per workload.

Workload Baseline (beta-1.3) Current working tree Improvement
Construct large document 0.609 ms 0.231 ms +62.0%
Sequential typing 1.730 ms 1.571 ms +9.2%
Scattered inserts 7.157 ms 5.876 ms +17.9%
Append after fragmentation 2.721 ms 1.116 ms +59.0%
Batch replacements 7.899 ms 5.488 ms +30.5%
Position round-trips 20.886 ms 13.866 ms +33.6%
Fragmented slices 2.469 ms 2.279 ms +7.7%
Whole-word search 10.682 ms 1.946 ms +81.8%
Combined p50 54.153 ms 32.372 ms +40.2%

Changes:

  • Removed temporary line-offset array allocations during typing.
  • Added constant-time treap split boundary exits.
  • Changed full-document search to flatten once and avoid repeated treap descents and whole-word charAt lookups.
  • Adaptive native line-break scanning with dense-newline fallback.
  • Replacement ranges discard deleted pieces without allocating both split halves; batch cache invalidation happens once.

ije added 3 commits July 17, 2026 18:56
50 latency in milliseconds; two warmups and nine measured samples per workload. Lower is better.

| Workload | Baseline | Round 1 | Round 2 | Round 3 | Improvement |
|---|---:|---:|---:|---:|---:|
| Construct large document | 0.549 | 0.503 | 0.548 | 0.501 | +8.7% |
| Sequential typing | 1.649 | 1.547 | 1.706 | 1.555 | +5.7% |
| Scattered inserts | 3.726 | 3.481 | 3.120 | 3.406 | +8.6% |
| Append after fragmentation | 1.003 | 0.995 | 0.629 | 0.784 | +21.9% |
| Batch replacements | 3.302 | 3.139 | 3.042 | 3.254 | +1.5% |
| Position round-trips | 11.630 | 11.497 | 10.759 | 12.414 | −6.7% |
| Fragmented slices | 1.721 | 1.467 | 1.586 | 1.688 | +1.9% |
| Whole-word search | 7.783 | 7.355 | 7.464 | 2.081 | +73.3% |
| **Combined p50** | **31.364** | **29.983** | **28.854** | **25.683** | **+18.1%** |
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jul 17, 2026 1:41pm
pierre-docs-diffshub Ready Ready Preview Jul 17, 2026 1:41pm
pierre-docs-trees Ready Ready Preview Jul 17, 2026 1:41pm
pierrejs-diff-demo Ready Ready Preview Jul 17, 2026 1:41pm

Request Review

@ije
ije marked this pull request as ready for review July 17, 2026 13:42
@ije

ije commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@ije
ije requested review from amadeus, fat and necolas July 17, 2026 13:43
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: e4a128c310

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ije
ije merged commit ef3b98a into beta-1.3 Jul 17, 2026
8 checks passed
@ije
ije deleted the ije/improve-piecetable-perf branch July 17, 2026 18:18
amadeus pushed a commit that referenced this pull request Jul 21, 2026
* [diffs/edit] improve picectable performance

50 latency in milliseconds; two warmups and nine measured samples per workload. Lower is better.

| Workload | Baseline | Round 1 | Round 2 | Round 3 | Improvement |
|---|---:|---:|---:|---:|---:|
| Construct large document | 0.549 | 0.503 | 0.548 | 0.501 | +8.7% |
| Sequential typing | 1.649 | 1.547 | 1.706 | 1.555 | +5.7% |
| Scattered inserts | 3.726 | 3.481 | 3.120 | 3.406 | +8.6% |
| Append after fragmentation | 1.003 | 0.995 | 0.629 | 0.784 | +21.9% |
| Batch replacements | 3.302 | 3.139 | 3.042 | 3.254 | +1.5% |
| Position round-trips | 11.630 | 11.497 | 10.759 | 12.414 | −6.7% |
| Fragmented slices | 1.721 | 1.467 | 1.586 | 1.688 | +1.9% |
| Whole-word search | 7.783 | 7.355 | 7.464 | 2.081 | +73.3% |
| **Combined p50** | **31.364** | **29.983** | **28.854** | **25.683** | **+18.1%** |

* another improvement

* another improvement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants