Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: do not rely on mutable Object and Function' constructor prop #56188

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Dec 9, 2024

Fixes: #55924

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Dec 9, 2024
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.51%. Comparing base (3851edf) to head (a245f3f).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/util/inspect.js 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56188      +/-   ##
==========================================
+ Coverage   88.49%   88.51%   +0.01%     
==========================================
  Files         656      656              
  Lines      189261   189281      +20     
  Branches    36348    36344       -4     
==========================================
+ Hits       167493   167535      +42     
+ Misses      14977    14973       -4     
+ Partials     6791     6773      -18     
Files with missing lines Coverage Δ
lib/internal/util/inspect.js 99.91% <96.00%> (-0.09%) ⬇️

... and 28 files with indirect coverage changes

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Could we split this PR into two? I would approve the function part right away, while I am still pondering about the prototype part.

lib/internal/util/inspect.js Show resolved Hide resolved
@aduh95
Copy link
Contributor Author

aduh95 commented Dec 9, 2024

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1654/

Results

                                                                                                            confidence improvement accuracy (*)    (**)   (***)
util/format.js type='many-%' n=1000000                                                                                     -0.36 %       ±0.80%  ±1.07%  ±1.39%
util/format.js type='no-replace-2' n=1000000                                                                               -1.20 %       ±1.84%  ±2.45%  ±3.19%
util/format.js type='no-replace' n=1000000                                                                                  0.41 %       ±0.85%  ±1.13%  ±1.47%
util/format.js type='number' n=1000000                                                                                     -0.56 %       ±1.47%  ±1.96%  ±2.55%
util/format.js type='object-%s' n=1000000                                                                          ***      2.00 %       ±0.28%  ±0.38%  ±0.49%
util/format.js type='object-to-string' n=1000000                                                                            1.69 %       ±2.25%  ±2.99%  ±3.90%
util/format.js type='only-objects' n=1000000                                                                       ***      3.91 %       ±0.32%  ±0.42%  ±0.55%
util/format.js type='replace-object' n=1000000                                                                              0.83 %       ±1.17%  ±1.57%  ±2.06%
util/format.js type='string-2' n=1000000                                                                                   -0.24 %       ±1.29%  ±1.72%  ±2.24%
util/format.js type='string' n=1000000                                                                                      0.99 %       ±1.08%  ±1.44%  ±1.88%
util/format.js type='unknown' n=1000000                                                                                    -0.24 %       ±2.46%  ±3.27%  ±4.26%
util/get-callsite.js method='CPP' n=1000000                                                                                 0.07 %       ±0.46%  ±0.61%  ±0.80%
util/get-callsite.js method='ErrorCallSites' n=1000000                                                                      0.23 %       ±0.46%  ±0.62%  ±0.81%
util/get-callsite.js method='ErrorCallSitesSerialized' n=1000000                                                            0.11 %       ±0.18%  ±0.24%  ±0.32%
util/inspect-array.js type='denseArray_showHidden' len=100 n=5000                                                           0.95 %       ±1.12%  ±1.49%  ±1.95%
util/inspect-array.js type='denseArray_showHidden' len=100000 n=5000                                                       -0.56 %       ±0.89%  ±1.19%  ±1.55%
util/inspect-array.js type='denseArray' len=100 n=5000                                                                      0.47 %       ±0.75%  ±1.00%  ±1.31%
util/inspect-array.js type='denseArray' len=100000 n=5000                                                          ***     -1.59 %       ±0.82%  ±1.09%  ±1.42%
util/inspect-array.js type='mixedArray' len=100 n=5000                                                                     -0.34 %       ±0.39%  ±0.51%  ±0.67%
util/inspect-array.js type='mixedArray' len=100000 n=5000                                                                   0.07 %       ±0.15%  ±0.20%  ±0.26%
util/inspect-array.js type='sparseArray' len=100 n=5000                                                                    -1.07 %       ±5.03%  ±6.71%  ±8.77%
util/inspect-array.js type='sparseArray' len=100000 n=5000                                                         ***     -3.28 %       ±1.37%  ±1.83%  ±2.42%
util/inspect-proxy.js isProxy=0 showProxy=0 n=100000                                                               ***     16.71 %       ±0.61%  ±0.81%  ±1.06%
util/inspect-proxy.js isProxy=0 showProxy=1 n=100000                                                               ***     16.95 %       ±0.56%  ±0.75%  ±0.97%
util/inspect-proxy.js isProxy=1 showProxy=0 n=100000                                                               ***     16.07 %       ±0.40%  ±0.53%  ±0.69%
util/inspect-proxy.js isProxy=1 showProxy=1 n=100000                                                               ***     16.47 %       ±0.40%  ±0.53%  ±0.69%
util/inspect.js option='colors' method='Array' n=80000                                                             ***     -0.63 %       ±0.36%  ±0.48%  ±0.63%
util/inspect.js option='colors' method='Date' n=80000                                                               **     -1.82 %       ±1.06%  ±1.42%  ±1.86%
util/inspect.js option='colors' method='Error' n=80000                                                              **     -0.89 %       ±0.53%  ±0.70%  ±0.91%
util/inspect.js option='colors' method='Number' n=80000                                                                    -0.48 %       ±2.41%  ±3.21%  ±4.18%
util/inspect.js option='colors' method='Object_deep_ln' n=80000                                                    ***      3.42 %       ±0.25%  ±0.34%  ±0.44%
util/inspect.js option='colors' method='Object_empty' n=80000                                                      ***     18.15 %       ±2.59%  ±3.45%  ±4.51%
util/inspect.js option='colors' method='Object' n=80000                                                            ***      2.07 %       ±0.47%  ±0.63%  ±0.81%
util/inspect.js option='colors' method='Set' n=80000                                                                       -0.72 %       ±0.82%  ±1.09%  ±1.42%
util/inspect.js option='colors' method='String_boxed' n=80000                                                      ***     -1.55 %       ±0.86%  ±1.14%  ±1.49%
util/inspect.js option='colors' method='String_complex' n=80000                                                             0.28 %       ±1.28%  ±1.70%  ±2.21%
util/inspect.js option='colors' method='String' n=80000                                                                     1.48 %       ±1.86%  ±2.48%  ±3.23%
util/inspect.js option='colors' method='TypedArray_extra' n=80000                                                          -0.16 %       ±0.28%  ±0.37%  ±0.48%
util/inspect.js option='colors' method='TypedArray' n=80000                                                        ***      1.05 %       ±0.30%  ±0.41%  ±0.53%
util/inspect.js option='none' method='Array' n=80000                                                                       -0.18 %       ±0.54%  ±0.72%  ±0.94%
util/inspect.js option='none' method='Date' n=80000                                                                         0.70 %       ±2.23%  ±3.00%  ±3.97%
util/inspect.js option='none' method='Error' n=80000                                                               ***     -3.01 %       ±1.39%  ±1.85%  ±2.41%
util/inspect.js option='none' method='Number' n=80000                                                                      -0.28 %       ±1.03%  ±1.37%  ±1.79%
util/inspect.js option='none' method='Object_deep_ln' n=80000                                                      ***      7.76 %       ±0.33%  ±0.44%  ±0.57%
util/inspect.js option='none' method='Object_empty' n=80000                                                        ***     19.59 %       ±1.86%  ±2.49%  ±3.27%
util/inspect.js option='none' method='Object' n=80000                                                              ***      5.01 %       ±0.85%  ±1.13%  ±1.47%
util/inspect.js option='none' method='Set' n=80000                                                                   *     -1.43 %       ±1.37%  ±1.82%  ±2.37%
util/inspect.js option='none' method='String_boxed' n=80000                                                                -0.65 %       ±1.30%  ±1.73%  ±2.26%
util/inspect.js option='none' method='String_complex' n=80000                                                               0.95 %       ±1.83%  ±2.45%  ±3.21%
util/inspect.js option='none' method='String' n=80000                                                                       1.18 %       ±1.37%  ±1.83%  ±2.39%
util/inspect.js option='none' method='TypedArray_extra' n=80000                                                     **     -0.66 %       ±0.45%  ±0.60%  ±0.78%
util/inspect.js option='none' method='TypedArray' n=80000                                                          ***     -1.26 %       ±0.56%  ±0.74%  ±0.97%
util/inspect.js option='showHidden' method='Array' n=80000                                                                  0.13 %       ±0.50%  ±0.66%  ±0.86%
util/inspect.js option='showHidden' method='Date' n=80000                                                            *     -1.49 %       ±1.36%  ±1.81%  ±2.37%
util/inspect.js option='showHidden' method='Error' n=80000                                                          **     -1.05 %       ±0.61%  ±0.81%  ±1.05%
util/inspect.js option='showHidden' method='Number' n=80000                                                                 0.93 %       ±4.24%  ±5.64%  ±7.34%
util/inspect.js option='showHidden' method='Object_deep_ln' n=80000                                                ***      8.88 %       ±0.36%  ±0.48%  ±0.64%
util/inspect.js option='showHidden' method='Object_empty' n=80000                                                  ***     24.47 %       ±2.85%  ±3.81%  ±4.97%
util/inspect.js option='showHidden' method='Object' n=80000                                                        ***      5.96 %       ±0.50%  ±0.66%  ±0.86%
util/inspect.js option='showHidden' method='Set' n=80000                                                             *     -1.74 %       ±1.51%  ±2.02%  ±2.63%
util/inspect.js option='showHidden' method='String_boxed' n=80000                                                          -0.41 %       ±0.62%  ±0.83%  ±1.08%
util/inspect.js option='showHidden' method='String_complex' n=80000                                                        -0.05 %       ±2.14%  ±2.85%  ±3.70%
util/inspect.js option='showHidden' method='String' n=80000                                                                -0.24 %       ±5.19%  ±6.90%  ±8.99%
util/inspect.js option='showHidden' method='TypedArray_extra' n=80000                                              ***     -0.51 %       ±0.29%  ±0.39%  ±0.51%
util/inspect.js option='showHidden' method='TypedArray' n=80000                                                     **     -0.50 %       ±0.37%  ±0.49%  ±0.63%

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM. Great that this also improves average cases!

lib/internal/util/inspect.js Show resolved Hide resolved
@BridgeAR BridgeAR added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Dec 9, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 9, 2024
@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 10, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 11, 2024
@nodejs-github-bot nodejs-github-bot merged commit 4a91507 into nodejs:main Dec 11, 2024
73 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 4a91507

@aduh95 aduh95 deleted the util-inspect-object-func branch December 11, 2024 11:13
targos pushed a commit that referenced this pull request Dec 13, 2024
PR-URL: #56188
Fixes: #55924
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

console/inspect output for functions is misleading in Hardened JS
4 participants