GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: optimize TextEncoder.encode for short strings by mertcanaltin · Pull Request #66831 · nodejs/node

Conversation

@mertcanaltin

@mertcanaltin mertcanaltin commented Oct 18, 2026

Copy link
Copy Markdown
Member

This pr improvement short strings for TextEncoder.encode.

Benchmark results:

(.venv) ➜  node git:(mert/textencoder-small-string) ✗ npx node-benchmark-compare te-clean.csv                                                        
                                                                          confidence improvement accuracy (*)   (**)  (***)
util/text-encoder.js op='encode' type='ascii' n=1000000 len=256                    *      1.67 %       ±1.45% ±1.94% ±2.54%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=32                   ***    127.18 %       ±1.93% ±2.58% ±3.40%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=256                 1.39 %       ±2.07% ±2.79% ±3.68%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=32         ***     85.44 %       ±2.43% ±3.27% ±4.31%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=256                -0.12 %       ±0.86% ±1.15% ±1.49%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=32         ***     74.83 %       ±1.45% ±1.94% ±2.54%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 6 comparisons, you can thus expect the following amount of false-positive results:
  0.30 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.06 false positives, when considering a   1% risk acceptance (**, ***),
  0.01 false positives, when considering a 0.1% risk acceptance (***)

I got help from Claude Opus 5.5. I reviewed the changes and ran the tests and benchmarks myself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss and AugustinMauroy reacted with rocket emoji
All reactions
  • 🚀 2 reactions
@mertcanaltin
lib: optimize TextEncoder.encode for short strings
caec80e
Assisted-by: Claude opus 5.5
Signed-off-by: Mert Can Altin <[email protected]>
@nodejs-github-bot nodejs-github-bot added encoding Issues and PRs related to the TextEncoder and TextDecoder APIs. needs-ci PRs that need a full CI run. labels Oct 18, 2026
aduh95
aduh95 reviewed Oct 18, 2026
View reviewed changes
Comment thread test/parallel/test-whatwg-encoding-custom-textencoder-short.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

mertcanaltin and others added 2 commits October 18, 2026 16:51
@mertcanaltin @aduh95
Update test/parallel/test-whatwg-encoding-custom-textencoder-short.js
a13f524
Co-authored-by: Antoine du Hamel <[email protected]>
@mertcanaltin
lint
5f342bd
@mertcanaltin
mertcanaltin requested a review from aduh95 October 18, 2026 13:58
@codecov

codecov Bot commented Oct 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.51%. Comparing base (e2d5522) to head (cdf9f11).
⚠️ Report is 74 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66831      +/-   ##
==========================================
+ Coverage   90.50%   90.51%   +0.01%     
==========================================
  Files         797      797              
  Lines      277793   278237     +444     
  Branches    53366    53466     +100     
==========================================
+ Hits       251405   251838     +433     
+ Misses      16801    16765      -36     
- Partials     9587     9634      +47     
Files with missing lines Coverage Δ
lib/internal/encoding.js 96.75% <100.00%> (+0.08%) ⬆️

... and 61 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig
anonrig reviewed Oct 19, 2026
View reviewed changes
Comment thread lib/internal/encoding.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@mertcanaltin
added comment
cdf9f11
@mertcanaltin
mertcanaltin requested a review from anonrig October 19, 2026 17:23
aduh95
aduh95 approved these changes Oct 21, 2026
View reviewed changes
@aduh95 aduh95 added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Benchmark GHA (util / text-encoder): https://github.com/nodejs/node/actions/runs/39607879277

Results

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

Benchmark results:

                                                                               confidence improvement accuracy (*)    (**)   (***)
util/text-encoder.js op='encode' type='ascii' n=1000000 len=1024                              -2.59 %      ±17.90% ±23.59% ±30.27%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=256                                2.01 %      ±22.07% ±29.09% ±37.33%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=32                        ***    172.54 %      ±31.10% ±41.03% ±52.72%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=8192                               0.66 %      ±16.04% ±21.14% ±27.13%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=1024                     2.12 %      ±18.63% ±24.56% ±31.51%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=256                     -1.85 %      ±19.74% ±26.02% ±33.39%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=32              ***    140.33 %      ±25.69% ±33.87% ±43.49%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=8192                     0.51 %       ±7.77% ±10.24% ±13.14%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=1024                    -1.62 %      ±16.32% ±21.51% ±27.60%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=256                     -1.19 %      ±18.34% ±24.17% ±31.01%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=32              ***    132.39 %      ±22.45% ±29.60% ±37.99%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=8192                    -0.16 %       ±7.29%  ±9.61% ±12.33%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=1024                          -0.30 %      ±17.92% ±23.63% ±30.31%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=256                            1.12 %      ±20.39% ±26.88% ±34.49%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=32                            -4.04 %      ±17.34% ±22.85% ±29.33%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=8192                           0.84 %       ±8.20% ±10.81% ±13.87%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=1024                 0.86 %      ±13.22% ±17.42% ±22.36%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=256                 -0.60 %      ±16.01% ±21.11% ±27.08%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=32                   2.46 %      ±19.34% ±25.49% ±32.70%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=8192                 0.50 %       ±5.69%  ±7.50%  ±9.62%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=1024                 0.03 %       ±9.57% ±12.61% ±16.19%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=256                  2.47 %      ±12.39% ±16.33% ±20.96%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=32                   2.54 %      ±17.87% ±23.56% ±30.23%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=8192                 0.04 %       ±6.00%  ±7.91% ±10.15%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 24 comparisons, you can thus
expect the following amount of false-positive results:
  1.20 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.24 false positives, when considering a   1% risk acceptance (**, ***),
  0.02 false positives, when considering a 0.1% risk acceptance (***)

[!WARNING]
Do not take GHA benchmark results as face value, always confirm them
using a dedicated machine, e.g. Jenkins CI.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 21, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78544/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig
anonrig approved these changes Oct 21, 2026
View reviewed changes
ronag
ronag approved these changes Oct 22, 2026
View reviewed changes
@ronag ronag added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 22, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Oct 22, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Commit Queue failed

   ✖  GitHub CI failed with status: FAILURE
   ✖  3 failure(s) on the last Jenkins CI run

The pull request was removed from the Commit Queue and labeled commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. . After resolving the failure, remove that label and add commit-queue PRs queued for automated landing through the Commit Queue. to retry.

Full Commit Queue output
�[36m⠋�[39m Loading data for nodejs/node/pull/66831
�[36m⠋�[39m Loading data for nodejs/node/pull/66831
�[36m⠋�[39m Getting collaborator contacts from README of nodejs/node
�[36m⠋�[39m Getting PR from nodejs/node/pull/66831
�[36m⠋�[39m Getting reviews from nodejs/node/pull/66831
�[36m⠋�[39m Getting comments from nodejs/node/pull/66831
�[36m⠋�[39m Getting commits from nodejs/node/pull/66831
✔  Done loading data for nodejs/node/pull/66831
----------------------------------- PR info ------------------------------------
Title      lib: optimize TextEncoder.encode for short strings (#66831)
Author     Mert Can Altin <[email protected]> (@mertcanaltin)
Branch     mertcanaltin:mert/textencoder-small-string -> nodejs:main
Labels     encoding, author ready, needs-ci, commit-queue, commit-queue-squash
Commits    4
 - lib: optimize TextEncoder.encode for short strings
 - Update test/parallel/test-whatwg-encoding-custom-textencoder-short.js
 - lint
 - added comment
Committers 2
 - Mert Can Altin <[email protected]>
 - GitHub <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/66831
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/66831
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sun, 18 Oct 2026 12:20:32 GMT
   ✔  Approvals: 3
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/66831#pullrequestreview-5600401401
   ✔  - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/66831#pullrequestreview-5601243454
   ✔  - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/66831#pullrequestreview-5620506743
   ✖  GitHub CI failed with status: FAILURE
   ℹ  Last Full PR CI on 2026-10-21T13:36:27Z: https://ci.nodejs.org/job/node-test-pull-request/78544/
�[36m⠙�[39m Querying data for job/node-test-pull-request/78544/
�[36m⠙�[39m Querying data for job/node-test-pull-request/78544/
�[36m⠙�[39m Querying API for job/node-test-pull-request/78544/
✔  Build data downloaded
�[36m⠹�[39m Querying failures of job/node-test-commit/93443/
�[36m⠹�[39m Querying failures of job/node-test-commit/93443/
�[36m⠹�[39m Querying API for job/node-test-commit-aix/66206/
�[36m⠹�[39m Querying API for job/node-test-commit-windows-fanned/81327/
�[36m⠸�[39m Querying API for job/node-test-commit-aix/nodes=aix73-power9/66206/
�[36m⠸�[39m Querying console text for job/node-test-commit-aix/nodes=aix73-power9/66206/
�[36m⠼�[39m Querying API for job/node-test-binary-windows-js-suites/44034/
�[36m⠴�[39m Querying API for job/node-test-binary-windows-js-suites/RUN_SUBSET=0,nodes=win11-vs2022-arm64-COMPILED_BY-vs2022_clang-arm64/44034/
�[36m⠴�[39m Querying API for job/node-test-binary-windows-js-suites/RUN_SUBSET=2,nodes=win2016-COMPILED_BY-vs2022-x86/44030/
�[36m⠦�[39m Querying console text for job/node-test-binary-windows-js-suites/RUN_SUBSET=0,nodes=win11-vs2022-arm64-COMPILED_BY-vs2022_clang-arm64/44034/
✔  Data downloaded
   ✖  3 failure(s) on the last Jenkins CI run
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu

View workflow run

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva panva added resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Oct 23, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 23, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78587/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 23, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 6353f40 into nodejs:main Oct 23, 2026
86 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Landed in 6353f40

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 23, 2026
@aduh95 aduh95 mentioned this pull request Oct 27, 2026
2026-10-28, Version 27.0.0-alpha.0.0.0 (Alpha) #67062
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@mertcanaltin @aduh95
lib: optimize TextEncoder.encode for short strings
1a8c999
Assisted-by: Claude opus 5.5
Signed-off-by: Mert Can Altin <[email protected]>
PR-URL: #66831
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@mertcanaltin @gabylb
lib: optimize TextEncoder.encode for short strings
89b378c
Assisted-by: Claude opus 5.5
Signed-off-by: Mert Can Altin <[email protected]>
PR-URL: nodejs#66831
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@anonrig anonrig anonrig approved these changes
@ronag ronag ronag approved these changes
@aduh95 aduh95 aduh95 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. encoding Issues and PRs related to the TextEncoder and TextDecoder APIs. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@mertcanaltin @nodejs-github-bot @anonrig @ronag @aduh95 @panva
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.