Skip to content

lib: add SafeArray to primordials and use it for FreeList - #36600

Open
ExE-Boss wants to merge 6 commits into
nodejs:mainfrom
ExE-Boss:lib/primordials/safe-array
Open

lib: add SafeArray to primordials and use it for FreeList#36600
ExE-Boss wants to merge 6 commits into
nodejs:mainfrom
ExE-Boss:lib/primordials/safe-array

Conversation

@ExE-Boss

Copy link
Copy Markdown
Contributor

Refs:#36304 (comment)
Refs:#36565

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@Lxxyx

Copy link
Copy Markdown
Member

Run Benchmark on my computer, seems the performance issues still exists.

 confidence improvement accuracy (*) (**) (***)
misc/freelist.js n=100000 *** -92.46 % ±1.94% ±2.61% ±3.46%
Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case there are 1 comparisons, you can thus
expect the following amount of false-positive results:
0.05 false positives, when considering a 5% risk acceptance (*, **, ***),
0.01 false positives, when considering a 1% risk acceptance (**, ***),
0.00 false positives, when considering a 0.1% risk acceptance (***)

@aduh95

aduh95 commented Dec 22, 2020

Copy link
Copy Markdown
Contributor

@ExE-Boss

Copy link
Copy Markdown
ContributorAuthor

@aduh95aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark confirmed very poor performance results…

 confidence improvement accuracy (*) (**) (***)
misc/freelist.js n=100000 *** -91.36 % ±3.89% ±5.24% ±6.96%

@targostargos added the lib / src Issues and PRs related to general changes in the lib or src directory. label Dec 27, 2020
@ExE-Boss

ExE-Boss commented Mar 7, 2021

Copy link
Copy Markdown
ContributorAuthor

If I had to guess, I’d say V8 is doing some inlining shenanigans when it detects a push or pop method on an ordinary array with %Array.prototype% in its [[Prototype]] internal slot.


By inlining the methods in #37649, I hope to make FreeList faster and resilient to mutation of %Array.prototype%.pop and %Array.prototype%.push

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

@ExE-Boss
ExE-Boss marked this pull request as draft July 28, 2026 05:24
@ExE-Boss
ExE-Boss marked this pull request as ready for review July 28, 2026 06:46
@codecov

codecovBot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.18182% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.14%. Comparing base (b2a024b) to head (ff89dbe).

Files with missing linesPatch %Lines
lib/internal/per_context/primordials.js92.85%3 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #36600 +/- ##
==========================================
- Coverage 90.15% 90.14% -0.02% 
==========================================
Files 744 744 Lines 242542 242582 +40 Branches 45690 45700 +10 ==========================================
+ Hits 218672 218682 +10 - Misses 15362 15394 +32 + Partials 8508 8506 -2 
Files with missing linesCoverage Δ
lib/internal/freelist.js100.00% <100.00%> (ø)
lib/internal/per_context/primordials.js98.78% <92.85%> (+0.44%)⬆️

... and 31 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.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / srcIssues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ExE-Boss@Lxxyx@aduh95@targos