assert: improve partialDeepStrictEqual#57370
Conversation
|
Review requested:
|
|
The new benchmark file somehow can't be applied. Local results (only three stars. I believe I have never had a 500x improvement before :D ) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57370 +/- ##
==========================================
- Coverage 90.23% 90.22% -0.01%
==========================================
Files 630 629 -1
Lines 185211 184976 -235
Branches 36245 36206 -39
==========================================
- Hits 167128 166898 -230
+ Misses 11056 11037 -19
- Partials 7027 7041 +14
🚀 New features to boost your workflow:
|
bc255c4 to
0a2a533
Compare
|
I marked the PR as semver minor due to the removal of the experimental warning. |
0a2a533 to
e053279
Compare
|
PTAL. I pushed another change that adds the changed part to the docs, marks a line as unreachable, and updated the examples in the documentation to be on multiple lines to easier read them. |
This significantly improves the assert.partialDeepStrictEqual implementation by reusing the already existing algorithm. It is significantly faster and handles edge cases like symbols identical as the deepStrictEqual algorithm. This is crucial to remove the experimental status from the implementation.
The current settings deactivate the extraProps handling, due to the current implementation failing on these cases.
These benchmarks are not frequently needed and just slow down the default benchmark suite. They are kept for users who want to run them but deactivated by default.
Each file should have a reasonable runtime while having a good accuracy. This adjust those up and down to have minimal runtimes with a good accuracy.
This improves the performance for array comparison by making the sparse array detection simpler. On top of that it adds a fast path for sets and maps that only contain objects as key.
assert.partialDeepStrictEqual now also handled error properties as expected. On top of that, the main implementation also handles non-string `name` and `message` properties and the comparison is a tad faster by removing duplicated comparison steps. As a drive-by fix this also cleans up some code by abstracting code and renaming variables for clarity.
These benchmarks are not frequently needed and just slow down the default benchmark suite. They are kept for users who want to run them but deactivated by default. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Each file should have a reasonable runtime while having a good accuracy. This adjust those up and down to have minimal runtimes with a good accuracy. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This improves the performance for array comparison by making the sparse array detection simpler. On top of that it adds a fast path for sets and maps that only contain objects as key. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
assert.partialDeepStrictEqual now also handled error properties as expected. On top of that, the main implementation also handles non-string `name` and `message` properties and the comparison is a tad faster by removing duplicated comparison steps. As a drive-by fix this also cleans up some code by abstracting code and renaming variables for clarity. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
The current implementation is well tested, fast and handles all known edge cases properly. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This significantly improves the assert.partialDeepStrictEqual implementation by reusing the already existing algorithm. It is significantly faster and handles edge cases like symbols identical as the deepStrictEqual algorithm. This is crucial to remove the experimental status from the implementation. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
The current settings deactivate the extraProps handling, due to the current implementation failing on these cases. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
These benchmarks are not frequently needed and just slow down the default benchmark suite. They are kept for users who want to run them but deactivated by default. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Each file should have a reasonable runtime while having a good accuracy. This adjust those up and down to have minimal runtimes with a good accuracy. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This improves the performance for array comparison by making the sparse array detection simpler. On top of that it adds a fast path for sets and maps that only contain objects as key. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
assert.partialDeepStrictEqual now also handled error properties as expected. On top of that, the main implementation also handles non-string `name` and `message` properties and the comparison is a tad faster by removing duplicated comparison steps. As a drive-by fix this also cleans up some code by abstracting code and renaming variables for clarity. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
The current implementation is well tested, fast and handles all known edge cases properly. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This significantly improves the assert.partialDeepStrictEqual implementation by reusing the already existing algorithm. It is significantly faster and handles edge cases like symbols identical as the deepStrictEqual algorithm. This is crucial to remove the experimental status from the implementation. PR-URL: nodejs#57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
The current settings deactivate the extraProps handling, due to the current implementation failing on these cases. PR-URL: nodejs#57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
These benchmarks are not frequently needed and just slow down the default benchmark suite. They are kept for users who want to run them but deactivated by default. PR-URL: nodejs#57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Each file should have a reasonable runtime while having a good accuracy. This adjust those up and down to have minimal runtimes with a good accuracy. PR-URL: nodejs#57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This improves the performance for array comparison by making the sparse array detection simpler. On top of that it adds a fast path for sets and maps that only contain objects as key. PR-URL: nodejs#57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
assert.partialDeepStrictEqual now also handled error properties as expected. On top of that, the main implementation also handles non-string `name` and `message` properties and the comparison is a tad faster by removing duplicated comparison steps. As a drive-by fix this also cleans up some code by abstracting code and renaming variables for clarity. PR-URL: nodejs#57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Notable changes: assert: * (SEMVER-MINOR) implement partial error comparison (Ruben Bridgewater) nodejs#57370 crypto: * (SEMVER-MINOR) add optional callback to `crypto.diffieHellman` (Filip Skokan) nodejs#57274 process: * (SEMVER-MINOR) add `execve` (Paolo Insogna) nodejs#56496 sqlite: * (SEMVER-MINOR) add `StatementSync.prototype.columns()` (Colin Ihrig) nodejs#57490 util: * (SEMVER-MINOR) expose diff function used by the assertion errors (Giovanni Bucci) nodejs#57462 PR-URL: nodejs#57694
Notable changes: assert: * (SEMVER-MINOR) implement partial error comparison (Ruben Bridgewater) #57370 * (SEMVER-MINOR) improve partialDeepStrictEqual (Ruben Bridgewater) #57370 assert,util: * (SEMVER-MINOR) improve performance (Ruben Bridgewater) #57370 benchmark: * (SEMVER-MINOR) adjust assert runtimes (Ruben Bridgewater) #57370 * (SEMVER-MINOR) skip running some assert benchmarks by default (Ruben Bridgewater) #57370 * (SEMVER-MINOR) add assert partialDeepStrictEqual benchmark (Ruben Bridgewater) #57370 cli: * (SEMVER-MINOR) allow --cpu-prof* in NODE_OPTIONS (Carlos Espa) #57018 crypto: * update root certificates to NSS 3.108 (Node.js GitHub Bot) #57381 * (SEMVER-MINOR) support --use-system-ca on Windows (Joyee Cheung) #56833 * (SEMVER-MINOR) added support for reading certificates from macOS system store (Tim Jacomb) #56599 deps: * update timezone to 2025a (Node.js GitHub Bot) #56876 * (SEMVER-MINOR) update ada to v3.0.1 (Yagiz Nizipli) #56452 deps,tools: * (SEMVER-MINOR) add zstd 1.5.6 (Jan Martin) #52100 dns: * (SEMVER-MINOR) add TLSA record query and parsing (Rithvik Vibhu) #52983 doc: * add @geeksilva97 to collaborators (Edy Silva) #57241 module: * (SEMVER-MINOR) use synchronous hooks for preparsing in import(cjs) (Joyee Cheung) #55698 * (SEMVER-MINOR) implement module.registerHooks() (Joyee Cheung) #55698 process: * (SEMVER-MINOR) add execve (Paolo Insogna) #56496 * (SEMVER-MINOR) add threadCpuUsage (Paolo Insogna) #56467 sqlite: * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490 * (SEMVER-MINOR) allow returning `ArrayBufferView`s from user-defined functions (René) #56790 src: * set signal inspector io thread name (RafaelGSS) #56416 * set thread name for main thread and v8 worker (RafaelGSS) #56416 * set worker thread name using worker.name (RafaelGSS) #56416 * use a default thread name for inspector (RafaelGSS) #56416 test: * (SEMVER-MINOR) add WPT for URLPattern (Yagiz Nizipli) #56452 tls: * (SEMVER-MINOR) implement tls.getCACertificates() (Joyee Cheung) #57107 url: * (SEMVER-MINOR) add URLPattern implementation (Yagiz Nizipli) #56452 util: * (SEMVER-MINOR) expose diff function used by the assertion errors (Giovanni Bucci) #57462 v8: * (SEMVER-MINOR) add v8.getCppHeapStatistics() method (Aditi) #57146 zlib: * (SEMVER-MINOR) add zstd support (Jan Martin) #52100 PR-URL: TODO
Notable changes: assert: * (SEMVER-MINOR) implement partial error comparison (Ruben Bridgewater) #57370 * (SEMVER-MINOR) improve partialDeepStrictEqual (Ruben Bridgewater) #57370 assert,util: * (SEMVER-MINOR) improve performance (Ruben Bridgewater) #57370 benchmark: * (SEMVER-MINOR) adjust assert runtimes (Ruben Bridgewater) #57370 * (SEMVER-MINOR) skip running some assert benchmarks by default (Ruben Bridgewater) #57370 * (SEMVER-MINOR) add assert partialDeepStrictEqual benchmark (Ruben Bridgewater) #57370 cli: * (SEMVER-MINOR) allow --cpu-prof* in NODE_OPTIONS (Carlos Espa) #57018 crypto: * update root certificates to NSS 3.108 (Node.js GitHub Bot) #57381 * (SEMVER-MINOR) support --use-system-ca on Windows (Joyee Cheung) #56833 * (SEMVER-MINOR) added support for reading certificates from macOS system store (Tim Jacomb) #56599 deps: * update timezone to 2025a (Node.js GitHub Bot) #56876 * (SEMVER-MINOR) update ada to v3.0.1 (Yagiz Nizipli) #56452 deps,tools: * (SEMVER-MINOR) add zstd 1.5.6 (Jan Martin) #52100 dns: * (SEMVER-MINOR) add TLSA record query and parsing (Rithvik Vibhu) #52983 doc: * add @geeksilva97 to collaborators (Edy Silva) #57241 module: * (SEMVER-MINOR) use synchronous hooks for preparsing in import(cjs) (Joyee Cheung) #55698 * (SEMVER-MINOR) implement module.registerHooks() (Joyee Cheung) #55698 process: * (SEMVER-MINOR) add execve (Paolo Insogna) #56496 * (SEMVER-MINOR) add threadCpuUsage (Paolo Insogna) #56467 sqlite: * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490 * (SEMVER-MINOR) allow returning `ArrayBufferView`s from user-defined functions (René) #56790 src: * set signal inspector io thread name (RafaelGSS) #56416 * set thread name for main thread and v8 worker (RafaelGSS) #56416 * set worker thread name using worker.name (RafaelGSS) #56416 * use a default thread name for inspector (RafaelGSS) #56416 test: * (SEMVER-MINOR) add WPT for URLPattern (Yagiz Nizipli) #56452 tls: * (SEMVER-MINOR) implement tls.getCACertificates() (Joyee Cheung) #57107 url: * (SEMVER-MINOR) add URLPattern implementation (Yagiz Nizipli) #56452 util: * (SEMVER-MINOR) expose diff function used by the assertion errors (Giovanni Bucci) #57462 v8: * (SEMVER-MINOR) add v8.getCppHeapStatistics() method (Aditi) #57146 zlib: * (SEMVER-MINOR) add zstd support (Jan Martin) #52100 PR-URL: #57840
This significantly improves the assert.partialDeepStrictEqual implementation by reusing the already existing algorithm. It is significantly faster and handles edge cases like symbols identical as the deepStrictEqual algorithm. This is crucial to remove the experimental status from the implementation. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
The current settings deactivate the extraProps handling, due to the current implementation failing on these cases. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
These benchmarks are not frequently needed and just slow down the default benchmark suite. They are kept for users who want to run them but deactivated by default. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Each file should have a reasonable runtime while having a good accuracy. This adjust those up and down to have minimal runtimes with a good accuracy. PR-URL: #57370 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
This significantly improves the assert.partialDeepStrictEqual
implementation (see benchmark below) by reusing the already existing algorithm.
It is significantly faster and handles all known edge cases like symbols
identical as the deepStrictEqual algorithm. This is crucial to
remove the experimental status from the implementation.
The old implementation could not yet handle some cases that
the benchmark handles. These are deactivated for now.
This is likely also a good idea due to the significant performance
difference between the two implementations.
I changed the stability index, since it's now handling all cases
properly.
This includes a performance improvement for
assert.deepStrictEqual().A few uncommon cases are actually slower due to seemingly V8
deoptimising the code when hitting rare cases. In reality, that should
not be an issue.
I noticed an interesting thing while working on this.
ObjectPrototypeHasOwnPropertyis significantly faster thanObjectHasOwn. This is something we could take advantageof in other parts of the code and I plan on opening an issue for
V8 to fix that.
Closes #56555