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

lib: reduce overhead of validateObject #49928

Merged
merged 3 commits into from
Oct 2, 2023

Conversation

H4ad
Copy link
Member

@H4ad H4ad commented Sep 28, 2023

Reducing the number of comparisons and allocations when using validateObject.

                                                               confidence improvement accuracy (*)      (**)     (***)
validators/validate-object.js objectToTest='array' n=100000           ***  28696.95 %    ±1448.43% ±1952.07% ±2591.59%
validators/validate-object.js objectToTest='function' n=100000        ***  28553.34 %    ±1501.99% ±2024.25% ±2687.42%
validators/validate-object.js objectToTest='null' n=100000            ***  25157.86 %    ±1483.43% ±1999.24% ±2654.21%
validators/validate-object.js objectToTest='object' n=100000          ***     60.87 %      ±10.64%   ±14.24%   ±18.70%

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

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Sep 28, 2023
@aduh95
Copy link
Contributor

aduh95 commented Sep 28, 2023

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

Results
                                                                                              confidence improvement accuracy (*)     (**)    (***)
fs/bench-accessSync.js n=100000 type='existing'                                                               1.41 %       ±5.64%   ±7.50%   ±9.77%
fs/bench-accessSync.js n=100000 type='non-existing'                                                           1.23 %       ±2.13%   ±2.83%   ±3.68%
fs/bench-accessSync.js n=100000 type='non-flat-existing'                                                      2.53 %       ±6.43%   ±8.56%  ±11.14%
fs/bench-copyFileSync.js n=10000 type='invalid'                                                              -6.73 %       ±9.69%  ±12.90%  ±16.79%
fs/bench-copyFileSync.js n=10000 type='valid'                                                                -1.04 %       ±3.95%   ±5.27%   ±6.87%
fs/bench-existsSync.js n=1000000 type='existing'                                                              0.53 %       ±0.98%   ±1.30%   ±1.69%
fs/bench-existsSync.js n=1000000 type='non-existing'                                                         -0.05 %       ±1.13%   ±1.50%   ±1.95%
fs/bench-existsSync.js n=1000000 type='non-flat-existing'                                             **      1.53 %       ±1.11%   ±1.48%   ±1.92%
fs/bench-mkdirp.js n=10000                                                                                    0.48 %       ±3.02%   ±4.01%   ±5.22%
fs/bench-opendir.js bufferSize=1024 mode='async' dir='lib' n=100                                              1.38 %       ±4.32%   ±5.76%   ±7.50%
fs/bench-opendir.js bufferSize=1024 mode='async' dir='test/parallel' n=100                                    0.71 %       ±3.02%   ±4.02%   ±5.24%
fs/bench-opendir.js bufferSize=1024 mode='callback' dir='lib' n=100                                          -0.11 %       ±3.27%   ±4.36%   ±5.67%
fs/bench-opendir.js bufferSize=1024 mode='callback' dir='test/parallel' n=100                                -0.19 %       ±1.59%   ±2.12%   ±2.76%
fs/bench-opendir.js bufferSize=1024 mode='sync' dir='lib' n=100                                              -0.46 %       ±3.95%   ±5.25%   ±6.83%
fs/bench-opendir.js bufferSize=1024 mode='sync' dir='test/parallel' n=100                                     3.72 %       ±5.63%   ±7.49%   ±9.75%
fs/bench-opendir.js bufferSize=32 mode='async' dir='lib' n=100                                                2.83 %       ±3.55%   ±4.73%   ±6.17%
fs/bench-opendir.js bufferSize=32 mode='async' dir='test/parallel' n=100                                      2.43 %       ±6.19%   ±8.24%  ±10.74%
fs/bench-opendir.js bufferSize=32 mode='callback' dir='lib' n=100                                             1.84 %       ±2.31%   ±3.08%   ±4.01%
fs/bench-opendir.js bufferSize=32 mode='callback' dir='test/parallel' n=100                                  -7.28 %       ±8.81%  ±11.72%  ±15.26%
fs/bench-opendir.js bufferSize=32 mode='sync' dir='lib' n=100                                                -3.85 %       ±5.03%   ±6.70%   ±8.76%
fs/bench-opendir.js bufferSize=32 mode='sync' dir='test/parallel' n=100                                       1.93 %       ±6.92%   ±9.21%  ±11.99%
fs/bench-opendir.js bufferSize=4 mode='async' dir='lib' n=100                                                -0.21 %       ±1.50%   ±1.99%   ±2.60%
fs/bench-opendir.js bufferSize=4 mode='async' dir='test/parallel' n=100                                       0.65 %       ±1.69%   ±2.25%   ±2.92%
fs/bench-opendir.js bufferSize=4 mode='callback' dir='lib' n=100                                             -0.32 %       ±2.36%   ±3.14%   ±4.09%
fs/bench-opendir.js bufferSize=4 mode='callback' dir='test/parallel' n=100                                   -1.03 %       ±2.36%   ±3.14%   ±4.10%
fs/bench-opendir.js bufferSize=4 mode='sync' dir='lib' n=100                                                  0.43 %       ±5.83%   ±7.77%  ±10.12%
fs/bench-opendir.js bufferSize=4 mode='sync' dir='test/parallel' n=100                                        5.71 %       ±6.53%   ±8.70%  ±11.32%
fs/bench-opendirSync.js n=1000 type='existing'                                                         *      3.12 %       ±2.83%   ±3.77%   ±4.91%
fs/bench-opendirSync.js n=1000 type='non-existing'                                                            1.57 %       ±7.79%  ±10.36%  ±13.48%
fs/bench-openSync.js n=100000 type='existing'                                                          *      4.18 %       ±4.02%   ±5.35%   ±6.96%
fs/bench-openSync.js n=100000 type='non-existing'                                                            -1.78 %       ±2.58%   ±3.44%   ±4.50%
fs/bench-readdir.js withFileTypes='false' dir='lib' n=10                                               *     -4.27 %       ±3.24%   ±4.31%   ±5.61%
fs/bench-readdir.js withFileTypes='false' dir='test/parallel' n=10                                            0.16 %       ±0.97%   ±1.28%   ±1.67%
fs/bench-readdir.js withFileTypes='true' dir='lib' n=10                                                       3.61 %       ±4.04%   ±5.38%   ±7.01%
fs/bench-readdir.js withFileTypes='true' dir='test/parallel' n=10                                            -0.03 %       ±0.89%   ±1.18%   ±1.54%
fs/bench-readdirSync.js withFileTypes='false' dir='lib' n=10                                                  6.22 %       ±9.63%  ±12.83%  ±16.74%
fs/bench-readdirSync.js withFileTypes='false' dir='test/parallel' n=10                                        0.29 %       ±1.10%   ±1.46%   ±1.90%
fs/bench-readdirSync.js withFileTypes='true' dir='lib' n=10                                                   0.51 %      ±10.06%  ±13.39%  ±17.43%
fs/bench-readdirSync.js withFileTypes='true' dir='test/parallel' n=10                                        -0.06 %       ±1.31%   ±1.75%   ±2.28%
fs/bench-realpath.js pathType='relative' n=10000                                                             -0.69 %       ±4.78%   ±6.36%   ±8.27%
fs/bench-realpath.js pathType='resolved' n=10000                                                              1.15 %       ±2.59%   ±3.45%   ±4.49%
fs/bench-realpathSync.js pathType='relative' n=10000                                                         -0.76 %       ±2.23%   ±2.98%   ±3.88%
fs/bench-realpathSync.js pathType='resolved' n=10000                                                          3.78 %       ±5.82%   ±7.80%  ±10.28%
fs/bench-stat-promise.js statType='fstat' n=200000                                                            1.08 %       ±1.95%   ±2.59%   ±3.38%
fs/bench-stat-promise.js statType='lstat' n=200000                                                            0.52 %       ±2.04%   ±2.71%   ±3.53%
fs/bench-stat-promise.js statType='stat' n=200000                                                             0.13 %       ±2.01%   ±2.68%   ±3.49%
fs/bench-stat.js statType='fstat' n=200000                                                            **      3.06 %       ±1.84%   ±2.45%   ±3.20%
fs/bench-stat.js statType='lstat' n=200000                                                                    0.55 %       ±1.83%   ±2.43%   ±3.17%
fs/bench-stat.js statType='stat' n=200000                                                                     2.10 %       ±2.18%   ±2.90%   ±3.78%
fs/bench-statSync-failure.js statSyncType='noThrow' n=1000000                                                -0.75 %       ±1.30%   ±1.73%   ±2.25%
fs/bench-statSync-failure.js statSyncType='throw' n=1000000                                            *      1.92 %       ±1.66%   ±2.22%   ±2.89%
fs/bench-statSync.js statSyncType='fstatSync' n=1000000                                                       0.30 %       ±0.92%   ±1.22%   ±1.60%
fs/bench-statSync.js statSyncType='lstatSync' n=1000000                                                       0.08 %       ±0.82%   ±1.09%   ±1.42%
fs/bench-statSync.js statSyncType='statSync' n=1000000                                                        1.45 %       ±1.66%   ±2.21%   ±2.89%
fs/bench-unlinkSync.js n=1000 type='existing'                                                                -2.26 %       ±5.01%   ±6.67%   ±8.69%
fs/bench-unlinkSync.js n=1000 type='non-existing'                                                             0.30 %       ±4.42%   ±5.89%   ±7.67%
fs/read-stream-throughput.js n=1024 highWaterMark=1024 filesize=1024000 encodingType='asc'                    0.04 %       ±2.41%   ±3.21%   ±4.18%
fs/read-stream-throughput.js n=1024 highWaterMark=1024 filesize=1024000 encodingType='buf'                   -3.11 %       ±3.33%   ±4.45%   ±5.82%
fs/read-stream-throughput.js n=1024 highWaterMark=1024 filesize=1024000 encodingType='utf'                   -0.41 %       ±1.42%   ±1.89%   ±2.47%
fs/read-stream-throughput.js n=1024 highWaterMark=1048576 filesize=1024000 encodingType='asc'                -0.41 %       ±1.90%   ±2.53%   ±3.30%
fs/read-stream-throughput.js n=1024 highWaterMark=1048576 filesize=1024000 encodingType='buf'                 0.77 %       ±2.76%   ±3.67%   ±4.78%
fs/read-stream-throughput.js n=1024 highWaterMark=1048576 filesize=1024000 encodingType='utf'                 0.08 %       ±0.83%   ±1.11%   ±1.44%
fs/read-stream-throughput.js n=1024 highWaterMark=4096 filesize=1024000 encodingType='asc'             *      1.73 %       ±1.55%   ±2.07%   ±2.70%
fs/read-stream-throughput.js n=1024 highWaterMark=4096 filesize=1024000 encodingType='buf'                    1.21 %       ±2.14%   ±2.84%   ±3.70%
fs/read-stream-throughput.js n=1024 highWaterMark=4096 filesize=1024000 encodingType='utf'                    1.09 %       ±1.51%   ±2.03%   ±2.67%
fs/read-stream-throughput.js n=1024 highWaterMark=65535 filesize=1024000 encodingType='asc'                  -1.10 %       ±3.02%   ±4.03%   ±5.25%
fs/read-stream-throughput.js n=1024 highWaterMark=65535 filesize=1024000 encodingType='buf'            *     -3.81 %       ±3.10%   ±4.12%   ±5.36%
fs/read-stream-throughput.js n=1024 highWaterMark=65535 filesize=1024000 encodingType='utf'                  -0.47 %       ±0.64%   ±0.85%   ±1.11%
fs/readfile-partitioned.js concurrent=1 len=1024 encoding='' duration=5                                      -1.27 %       ±1.36%   ±1.82%   ±2.37%
fs/readfile-partitioned.js concurrent=1 len=1024 encoding='utf-8' duration=5                                 -0.56 %       ±1.15%   ±1.53%   ±2.00%
fs/readfile-partitioned.js concurrent=1 len=16777216 encoding='' duration=5                                   0.35 %       ±1.73%   ±2.30%   ±3.00%
fs/readfile-partitioned.js concurrent=1 len=16777216 encoding='utf-8' duration=5                              2.98 %       ±5.06%   ±6.76%   ±8.84%
fs/readfile-partitioned.js concurrent=10 len=1024 encoding='' duration=5                               *     -1.81 %       ±1.53%   ±2.03%   ±2.64%
fs/readfile-partitioned.js concurrent=10 len=1024 encoding='utf-8' duration=5                         **     -2.57 %       ±1.79%   ±2.39%   ±3.11%
fs/readfile-partitioned.js concurrent=10 len=16777216 encoding='' duration=5                                  1.47 %       ±2.35%   ±3.12%   ±4.07%
fs/readfile-partitioned.js concurrent=10 len=16777216 encoding='utf-8' duration=5                             0.66 %       ±3.66%   ±4.88%   ±6.35%
fs/readfile-permission-enabled.js concurrent=1 len=1024 encoding='' duration=5                               -1.61 %       ±1.67%   ±2.22%   ±2.89%
fs/readfile-permission-enabled.js concurrent=1 len=1024 encoding='utf-8' duration=5                          -0.86 %       ±1.45%   ±1.93%   ±2.51%
fs/readfile-permission-enabled.js concurrent=1 len=16777216 encoding='' duration=5                            0.22 %       ±5.10%   ±6.79%   ±8.84%
fs/readfile-permission-enabled.js concurrent=1 len=16777216 encoding='utf-8' duration=5                      -0.28 %       ±1.73%   ±2.33%   ±3.08%
fs/readfile-permission-enabled.js concurrent=10 len=1024 encoding='' duration=5                              -0.49 %       ±1.86%   ±2.48%   ±3.23%
fs/readfile-permission-enabled.js concurrent=10 len=1024 encoding='utf-8' duration=5                  **     -2.54 %       ±1.89%   ±2.52%   ±3.30%
fs/readfile-permission-enabled.js concurrent=10 len=16777216 encoding='' duration=5                          -2.96 %       ±4.69%   ±6.24%   ±8.12%
fs/readfile-permission-enabled.js concurrent=10 len=16777216 encoding='utf-8' duration=5                     -1.07 %       ±1.78%   ±2.36%   ±3.08%
fs/readfile-promises.js concurrent=1 len=1024 encoding='' duration=5                                          1.22 %       ±2.26%   ±3.01%   ±3.92%
fs/readfile-promises.js concurrent=1 len=1024 encoding='utf-8' duration=5                                     0.57 %       ±2.33%   ±3.10%   ±4.04%
fs/readfile-promises.js concurrent=1 len=16777216 encoding='' duration=5                                     -0.83 %       ±1.07%   ±1.43%   ±1.86%
fs/readfile-promises.js concurrent=1 len=16777216 encoding='utf-8' duration=5                                -0.23 %       ±0.91%   ±1.22%   ±1.58%
fs/readfile-promises.js concurrent=1 len=33554432 encoding='' duration=5                                      0.64 %       ±0.98%   ±1.30%   ±1.69%
fs/readfile-promises.js concurrent=1 len=33554432 encoding='utf-8' duration=5                                -0.08 %       ±0.71%   ±0.94%   ±1.22%
fs/readfile-promises.js concurrent=1 len=4194304 encoding='' duration=5                                       0.70 %       ±1.27%   ±1.69%   ±2.20%
fs/readfile-promises.js concurrent=1 len=4194304 encoding='utf-8' duration=5                                 -1.03 %       ±1.96%   ±2.64%   ±3.49%
fs/readfile-promises.js concurrent=1 len=524288 encoding='' duration=5                                        1.30 %       ±3.15%   ±4.19%   ±5.46%
fs/readfile-promises.js concurrent=1 len=524288 encoding='utf-8' duration=5                                  -0.57 %       ±1.81%   ±2.40%   ±3.13%
fs/readfile-promises.js concurrent=1 len=8388608 encoding='' duration=5                                      -0.07 %       ±1.23%   ±1.64%   ±2.14%
fs/readfile-promises.js concurrent=1 len=8388608 encoding='utf-8' duration=5                                 -0.36 %       ±0.79%   ±1.05%   ±1.36%
fs/readfile-promises.js concurrent=10 len=1024 encoding='' duration=5                                  *     -1.55 %       ±1.23%   ±1.64%   ±2.14%
fs/readfile-promises.js concurrent=10 len=1024 encoding='utf-8' duration=5                                    0.28 %       ±1.58%   ±2.10%   ±2.73%
fs/readfile-promises.js concurrent=10 len=16777216 encoding='' duration=5                                     1.01 %       ±1.88%   ±2.50%   ±3.25%
fs/readfile-promises.js concurrent=10 len=16777216 encoding='utf-8' duration=5                               -0.08 %       ±1.05%   ±1.39%   ±1.82%
fs/readfile-promises.js concurrent=10 len=33554432 encoding='' duration=5                                    -0.24 %       ±1.11%   ±1.47%   ±1.92%
fs/readfile-promises.js concurrent=10 len=33554432 encoding='utf-8' duration=5                               -0.09 %       ±0.87%   ±1.17%   ±1.54%
fs/readfile-promises.js concurrent=10 len=4194304 encoding='' duration=5                                     -0.68 %       ±2.59%   ±3.45%   ±4.50%
fs/readfile-promises.js concurrent=10 len=4194304 encoding='utf-8' duration=5                                -0.20 %       ±1.42%   ±1.88%   ±2.45%
fs/readfile-promises.js concurrent=10 len=524288 encoding='' duration=5                                      -0.35 %       ±3.06%   ±4.07%   ±5.30%
fs/readfile-promises.js concurrent=10 len=524288 encoding='utf-8' duration=5                                 -0.04 %       ±1.00%   ±1.33%   ±1.73%
fs/readfile-promises.js concurrent=10 len=8388608 encoding='' duration=5                                      0.72 %       ±1.62%   ±2.15%   ±2.81%
fs/readfile-promises.js concurrent=10 len=8388608 encoding='utf-8' duration=5                          *      1.52 %       ±1.40%   ±1.86%   ±2.42%
fs/readfile.js concurrent=1 len=1024 encoding='' duration=5                                                   0.44 %       ±1.31%   ±1.74%   ±2.26%
fs/readfile.js concurrent=1 len=1024 encoding='utf-8' duration=5                                             -0.11 %       ±1.23%   ±1.64%   ±2.13%
fs/readfile.js concurrent=1 len=16777216 encoding='' duration=5                                               2.60 %       ±4.37%   ±5.82%   ±7.58%
fs/readfile.js concurrent=1 len=16777216 encoding='utf-8' duration=5                                         -0.40 %       ±0.79%   ±1.06%   ±1.37%
fs/readfile.js concurrent=10 len=1024 encoding='' duration=5                                                  0.54 %       ±1.32%   ±1.75%   ±2.28%
fs/readfile.js concurrent=10 len=1024 encoding='utf-8' duration=5                                             0.13 %       ±1.42%   ±1.89%   ±2.46%
fs/readfile.js concurrent=10 len=16777216 encoding='' duration=5                                              0.09 %       ±5.44%   ±7.24%   ±9.44%
fs/readfile.js concurrent=10 len=16777216 encoding='utf-8' duration=5                                         0.24 %       ±1.60%   ±2.13%   ±2.77%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='existing' encoding='undefined'                     5.77 %       ±8.20%  ±10.92%  ±14.23%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='existing' encoding='utf8'                          0.62 %      ±10.08%  ±13.42%  ±17.48%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='non-existing' encoding='undefined'                 1.76 %      ±10.11%  ±13.45%  ±17.50%
fs/readFileSync.js n=10000 hasFileDescriptor='false' path='non-existing' encoding='utf8'                      1.31 %       ±8.19%  ±10.90%  ±14.18%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='existing' encoding='undefined'                     -4.90 %       ±7.52%  ±10.01%  ±13.03%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='existing' encoding='utf8'                          -3.61 %       ±9.38%  ±12.48%  ±16.24%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='non-existing' encoding='undefined'                 -0.21 %       ±7.49%   ±9.96%  ±12.96%
fs/readFileSync.js n=10000 hasFileDescriptor='true' path='non-existing' encoding='utf8'                       5.21 %       ±9.34%  ±12.43%  ±16.17%
fs/write-stream-throughput.js size=1024 encodingType='asc' dur=5                                             -0.47 %       ±1.68%   ±2.24%   ±2.92%
fs/write-stream-throughput.js size=1024 encodingType='buf' dur=5                                       *     -1.90 %       ±1.48%   ±1.97%   ±2.56%
fs/write-stream-throughput.js size=1024 encodingType='utf' dur=5                                              1.26 %       ±1.39%   ±1.86%   ±2.42%
fs/write-stream-throughput.js size=1048576 encodingType='asc' dur=5                                          -1.59 %       ±1.77%   ±2.36%   ±3.07%
fs/write-stream-throughput.js size=1048576 encodingType='buf' dur=5                                          -0.32 %       ±0.81%   ±1.08%   ±1.41%
fs/write-stream-throughput.js size=1048576 encodingType='utf' dur=5                                          -0.81 %       ±1.69%   ±2.25%   ±2.94%
fs/write-stream-throughput.js size=2 encodingType='asc' dur=5                                                 0.29 %       ±2.16%   ±2.87%   ±3.74%
fs/write-stream-throughput.js size=2 encodingType='buf' dur=5                                        ***      3.15 %       ±1.68%   ±2.23%   ±2.90%
fs/write-stream-throughput.js size=2 encodingType='utf' dur=5                                                 0.63 %       ±3.35%   ±4.46%   ±5.81%
fs/write-stream-throughput.js size=65535 encodingType='asc' dur=5                                            -0.56 %       ±1.16%   ±1.54%   ±2.02%
fs/write-stream-throughput.js size=65535 encodingType='buf' dur=5                                            -0.12 %       ±0.99%   ±1.32%   ±1.72%
fs/write-stream-throughput.js size=65535 encodingType='utf' dur=5                                            -1.01 %       ±1.19%   ±1.59%   ±2.09%
fs/writefile-promises.js concurrent=1 size=1024 encodingType='asc' duration=5                                 1.36 %       ±2.99%   ±3.98%   ±5.19%
fs/writefile-promises.js concurrent=1 size=1024 encodingType='buf' duration=5                                -0.01 %       ±2.98%   ±3.97%   ±5.19%
fs/writefile-promises.js concurrent=1 size=1024 encodingType='utf' duration=5                                 0.39 %       ±3.03%   ±4.03%   ±5.25%
fs/writefile-promises.js concurrent=1 size=1048576 encodingType='asc' duration=5                             -0.63 %       ±1.67%   ±2.23%   ±2.91%
fs/writefile-promises.js concurrent=1 size=1048576 encodingType='buf' duration=5                              0.32 %       ±1.02%   ±1.37%   ±1.78%
fs/writefile-promises.js concurrent=1 size=1048576 encodingType='utf' duration=5                              0.07 %       ±2.44%   ±3.26%   ±4.26%
fs/writefile-promises.js concurrent=1 size=2 encodingType='asc' duration=5                            **      4.20 %       ±2.93%   ±3.90%   ±5.08%
fs/writefile-promises.js concurrent=1 size=2 encodingType='buf' duration=5                                    1.18 %       ±2.63%   ±3.50%   ±4.56%
fs/writefile-promises.js concurrent=1 size=2 encodingType='utf' duration=5                                   -0.87 %       ±3.10%   ±4.12%   ±5.37%
fs/writefile-promises.js concurrent=1 size=65535 encodingType='asc' duration=5                               -0.20 %       ±3.57%   ±4.75%   ±6.18%
fs/writefile-promises.js concurrent=1 size=65535 encodingType='buf' duration=5                               -0.98 %       ±3.11%   ±4.14%   ±5.40%
fs/writefile-promises.js concurrent=1 size=65535 encodingType='utf' duration=5                               -0.84 %       ±2.64%   ±3.51%   ±4.57%
fs/writefile-promises.js concurrent=10 size=1024 encodingType='asc' duration=5                               -0.57 %       ±1.59%   ±2.11%   ±2.75%
fs/writefile-promises.js concurrent=10 size=1024 encodingType='buf' duration=5                               -0.11 %       ±1.44%   ±1.92%   ±2.50%
fs/writefile-promises.js concurrent=10 size=1024 encodingType='utf' duration=5                               -1.06 %       ±2.62%   ±3.48%   ±4.54%
fs/writefile-promises.js concurrent=10 size=1048576 encodingType='asc' duration=5                            -0.06 %       ±1.18%   ±1.57%   ±2.05%
fs/writefile-promises.js concurrent=10 size=1048576 encodingType='buf' duration=5                             0.76 %       ±1.39%   ±1.84%   ±2.40%
fs/writefile-promises.js concurrent=10 size=1048576 encodingType='utf' duration=5                            -0.09 %       ±1.34%   ±1.78%   ±2.32%
fs/writefile-promises.js concurrent=10 size=2 encodingType='asc' duration=5                                   1.08 %       ±1.53%   ±2.04%   ±2.66%
fs/writefile-promises.js concurrent=10 size=2 encodingType='buf' duration=5                                   0.66 %       ±1.78%   ±2.36%   ±3.08%
fs/writefile-promises.js concurrent=10 size=2 encodingType='utf' duration=5                                   0.97 %       ±2.07%   ±2.76%   ±3.59%
fs/writefile-promises.js concurrent=10 size=65535 encodingType='asc' duration=5                              -0.74 %       ±2.17%   ±2.89%   ±3.77%
fs/writefile-promises.js concurrent=10 size=65535 encodingType='buf' duration=5                               0.32 %       ±0.82%   ±1.10%   ±1.43%
fs/writefile-promises.js concurrent=10 size=65535 encodingType='utf' duration=5                        *     -1.84 %       ±1.42%   ±1.89%   ±2.47%
streams/creation.js kind='duplex' n=50000000                                                                 -0.86 %       ±1.27%   ±1.69%   ±2.20%
streams/creation.js kind='readable' n=50000000                                                                1.42 %       ±3.96%   ±5.30%   ±6.95%
streams/creation.js kind='transform' n=50000000                                                              -0.57 %       ±2.55%   ±3.42%   ±4.51%
streams/creation.js kind='writable' n=50000000                                                                0.39 %       ±1.33%   ±1.78%   ±2.31%
streams/destroy.js kind='duplex' n=1000000                                                             *      6.26 %       ±4.86%   ±6.47%   ±8.43%
streams/destroy.js kind='readable' n=1000000                                                                 -1.13 %       ±3.41%   ±4.54%   ±5.91%
streams/destroy.js kind='transform' n=1000000                                                                -3.60 %       ±5.73%   ±7.63%   ±9.94%
streams/destroy.js kind='writable' n=1000000                                                                 -0.48 %       ±3.32%   ±4.41%   ±5.75%
streams/pipe-object-mode.js n=5000000                                                                        -0.49 %       ±3.84%   ±5.11%   ±6.64%
streams/pipe.js n=5000000                                                                                     1.53 %       ±2.45%   ±3.27%   ±4.26%
streams/readable-async-iterator.js sync='no' n=100000                                                        -3.63 %       ±5.09%   ±6.78%   ±8.85%
streams/readable-async-iterator.js sync='yes' n=100000                                                       -2.28 %       ±5.47%   ±7.29%   ±9.50%
streams/readable-bigread.js n=1000                                                                           -0.42 %       ±1.78%   ±2.37%   ±3.09%
streams/readable-bigunevenread.js n=1000                                                                      0.91 %       ±6.13%   ±8.16%  ±10.62%
streams/readable-boundaryread.js type='buffer' n=2000                                                         1.28 %       ±2.03%   ±2.70%   ±3.52%
streams/readable-boundaryread.js type='string' n=2000                                                         0.31 %       ±0.61%   ±0.81%   ±1.05%
streams/readable-from.js n=10000000                                                                           1.26 %       ±2.01%   ±2.68%   ±3.48%
streams/readable-readall.js n=5000                                                                            0.38 %       ±0.67%   ±0.89%   ±1.16%
streams/readable-unevenread.js n=1000                                                                        -0.12 %       ±0.52%   ±0.69%   ±0.90%
streams/writable-manywrites.js len=1024 callback='no' writev='no' sync='no' n=2000000                        -0.11 %       ±2.74%   ±3.65%   ±4.75%
streams/writable-manywrites.js len=1024 callback='no' writev='no' sync='yes' n=2000000                       -1.32 %       ±9.81%  ±13.05%  ±16.98%
streams/writable-manywrites.js len=1024 callback='no' writev='yes' sync='no' n=2000000                        1.86 %       ±7.78%  ±10.35%  ±13.48%
streams/writable-manywrites.js len=1024 callback='no' writev='yes' sync='yes' n=2000000                      -0.45 %       ±8.91%  ±11.86%  ±15.43%
streams/writable-manywrites.js len=1024 callback='yes' writev='no' sync='no' n=2000000                        1.64 %       ±3.61%   ±4.80%   ±6.24%
streams/writable-manywrites.js len=1024 callback='yes' writev='no' sync='yes' n=2000000                       1.94 %       ±9.83%  ±13.08%  ±17.03%
streams/writable-manywrites.js len=1024 callback='yes' writev='yes' sync='no' n=2000000                      -4.87 %       ±6.94%   ±9.24%  ±12.04%
streams/writable-manywrites.js len=1024 callback='yes' writev='yes' sync='yes' n=2000000                      2.62 %       ±8.84%  ±11.77%  ±15.32%
streams/writable-manywrites.js len=32768 callback='no' writev='no' sync='no' n=2000000                        0.65 %       ±3.25%   ±4.33%   ±5.64%
streams/writable-manywrites.js len=32768 callback='no' writev='no' sync='yes' n=2000000                      -1.31 %       ±3.00%   ±3.99%   ±5.20%
streams/writable-manywrites.js len=32768 callback='no' writev='yes' sync='no' n=2000000                      -0.06 %       ±3.17%   ±4.21%   ±5.49%
streams/writable-manywrites.js len=32768 callback='no' writev='yes' sync='yes' n=2000000                     -1.07 %       ±3.14%   ±4.18%   ±5.44%
streams/writable-manywrites.js len=32768 callback='yes' writev='no' sync='no' n=2000000                      -1.98 %       ±3.26%   ±4.34%   ±5.65%
streams/writable-manywrites.js len=32768 callback='yes' writev='no' sync='yes' n=2000000                     -0.21 %       ±3.47%   ±4.62%   ±6.01%
streams/writable-manywrites.js len=32768 callback='yes' writev='yes' sync='no' n=2000000                      0.70 %       ±3.32%   ±4.42%   ±5.76%
streams/writable-manywrites.js len=32768 callback='yes' writev='yes' sync='yes' n=2000000                     1.93 %       ±3.99%   ±5.31%   ±6.91%
validators/validate-object.js objectToTest='array' n=100000                                          ***  13318.50 %     ±491.20% ±662.00% ±878.88%
validators/validate-object.js objectToTest='function' n=100000                                       ***  14430.45 %     ±528.01% ±711.61% ±944.74%
validators/validate-object.js objectToTest='null' n=100000                                           ***  12547.62 %     ±433.24% ±583.89% ±775.17%
validators/validate-object.js objectToTest='object' n=100000                                         ***     58.94 %       ±5.68%   ±7.62%  ±10.03%

Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

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

🚀

@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Sep 28, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 28, 2023
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

I wonder if it wouldn't be better to just split it into 2 functions (one for default other with options) and if that would let us avoid the bit sorcery and still see the performance improvement.

@H4ad
Copy link
Member Author

H4ad commented Sep 28, 2023

@benjamingr Maybe, the bit sorcery still needed to not have a bunch of duplicated functions (one for each combination).

I can introduce internal functions but I don't think that will be worth adding one more hideStackFrames if I throw an exception.
It could be two functions, maybe validateObject and validateObjectWithOptions but this didn't look good to me, so I will keep it as is for now unless you have some suggestions.

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

According to #49928 (comment), this has little effect on the overall performance of Node.js. Still a good change to see.

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the performance Issues and PRs related to the performance of Node.js. label Sep 29, 2023
@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Sep 30, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Sep 30, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 2, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 2, 2023
@nodejs-github-bot nodejs-github-bot merged commit 952cf0d into nodejs:main Oct 2, 2023
30 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 952cf0d

@H4ad H4ad deleted the perf/validate-objects branch October 2, 2023 12:57
alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
PR-URL: nodejs#49928
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos pushed a commit that referenced this pull request Nov 11, 2023
PR-URL: #49928
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
debadree25 pushed a commit to debadree25/node that referenced this pull request Apr 15, 2024
PR-URL: nodejs#49928
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@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. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants