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

avoid deoptimization #4

Merged
merged 1 commit into from Sep 5, 2022
Merged

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 5, 2022

deoptigate reports an out of bounds error resulting in a eager bailout. My benchmarks are on node 18.

My benchmark:

'use strict'

const Benchmark = require('benchmark');
const fastQueryString = require("./lib/index.js");
var suite = new Benchmark.Suite;

suite.add('fastQueryString', function() {
  fastQueryString.parse("hello=world&foo=bar&foo=baz")
})
// add listeners
.on('cycle', function(event) {
  console.log(String(event.target));
})
.on('complete', function() {
  console.log('Fastest is ' + this.filter('fastest').map('name'));
})
.run();

before:

fastQueryString x 3,002,304 ops/sec ±0.48% (94 runs sampled)
Fastest is fastQueryString

after:

fastQueryString x 3,661,458 ops/sec ±0.76% (94 runs sampled)
Fastest is fastQueryString

@Uzlopak Uzlopak mentioned this pull request Sep 5, 2022
@anonrig anonrig merged commit c9d079f into anonrig:main Sep 5, 2022
@anonrig
Copy link
Owner

anonrig commented Sep 5, 2022

Thank you for your contribution. Really nice catch!

@Uzlopak Uzlopak deleted the avoid-deoptimization-v2 branch September 5, 2022 20:17
@anonrig
Copy link
Owner

anonrig commented Sep 5, 2022

The new benchmarks are:

╔═════════════════════════════════════════╤═════════╤═══════════════════╤═══════════╤══════════════════════════╗
║ Slower tests                            │ Samples │            Result │ Tolerance │ Difference with previous ║
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ qs                                      │   10000 │  314490.53 op/sec │  ± 1.30 % │                          ║
║ query-string                            │   10000 │  335943.68 op/sec │  ± 1.26 % │ + 6.82 %                 ║
║ URLSearchParams-with-Object.fromEntries │   10000 │  841094.46 op/sec │  ± 2.71 % │ + 150.37 %               ║
║ URLSearchParams-with-construct          │   10000 │ 1230055.12 op/sec │  ± 3.04 % │ + 46.24 %                ║
║ node:querystring                        │   10000 │ 1402133.99 op/sec │  ± 4.02 % │ + 13.99 %                ║
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ Fastest test                            │ Samples │            Result │ Tolerance │ Difference with previous ║
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────┼──────────────────────────╢
║ fast-querystring                        │   10000 │ 1620376.82 op/sec │  ± 3.72 % │ + 15.57 %                ║
╚═════════════════════════════════════════╧═════════╧═══════════════════╧═══════════╧══════════════════════════╝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants