-
Notifications
You must be signed in to change notification settings - Fork 376
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
Improve performance of hashObject
#594
Merged
Merged
Commits on Oct 27, 2023
-
perf: hashObject: use pre-calculated
sortedLabelNames
Since label names are predefined ahead-of-time and constant during runtime, we can sort them before-hand and use them when running `hashObject. node v18.18.2 ``` http fetch GET 200 https://registry.npmjs.org/prom-client 83ms http fetch GET 200 https://registry.npmjs.org/prom-client/-/prom-client-15.0.0.tgz 42ms + [email protected] added 4 packages from 4 contributors and audited 4 packages in 0.382s found 0 vulnerabilities - histogram ➭ observe#1 with 64 ➭ current x 104,381 ops/sec ±0.42% (99 runs sampled) - histogram ➭ observe#1 with 64 ➭ prom-client@latest x 103,709 ops/sec ±0.72% (96 runs sampled) - histogram ➭ observe#2 with 8 ➭ current x 68,178 ops/sec ±0.20% (98 runs sampled) - histogram ➭ observe#2 with 8 ➭ prom-client@latest x 53,510 ops/sec ±0.18% (97 runs sampled) - histogram ➭ observe#2 with 4 and 2 with 2 ➭ current x 34,169 ops/sec ±0.22% (97 runs sampled) - histogram ➭ observe#2 with 4 and 2 with 2 ➭ prom-client@latest x 28,170 ops/sec ±0.32% (97 runs sampled) - histogram ➭ observe#2 with 2 and 2 with 4 ➭ current x 36,057 ops/sec ±0.36% (97 runs sampled) - histogram ➭ observe#2 with 2 and 2 with 4 ➭ prom-client@latest x 28,804 ops/sec ±0.20% (98 runs sampled) - histogram ➭ observe#6 with 2 ➭ current x 23,360 ops/sec ±0.14% (97 runs sampled) - histogram ➭ observe#6 with 2 ➭ prom-client@latest x 19,420 ops/sec ±0.36% (96 runs sampled) - counter ➭ inc ➭ current x 59,643,643 ops/sec ±0.13% (101 runs sampled) - counter ➭ inc ➭ prom-client@latest x 37,023,723 ops/sec ±0.46% (95 runs sampled) - counter ➭ inc with labels ➭ current x 84,762 ops/sec ±0.25% (97 runs sampled) - counter ➭ inc with labels ➭ prom-client@latest x 67,225 ops/sec ±0.62% (95 runs sampled) - gauge ➭ inc ➭ current x 61,652,788 ops/sec ±0.41% (96 runs sampled) - gauge ➭ inc ➭ prom-client@latest x 31,247,588 ops/sec ±0.28% (98 runs sampled) - gauge ➭ inc with labels ➭ current x 86,552 ops/sec ±0.54% (97 runs sampled) - gauge ➭ inc with labels ➭ prom-client@latest x 64,590 ops/sec ±0.47% (95 runs sampled) - summary ➭ observe#1 with 64 ➭ current x 87,909 ops/sec ±0.18% (98 runs sampled) - summary ➭ observe#1 with 64 ➭ prom-client@latest x 94,806 ops/sec ±0.87% (89 runs sampled) - summary ➭ observe#2 with 8 ➭ current x 61,909 ops/sec ±0.15% (99 runs sampled) - summary ➭ observe#2 with 8 ➭ prom-client@latest x 49,337 ops/sec ±0.35% (100 runs sampled) - summary ➭ observe#2 with 4 and 2 with 2 ➭ current x 32,320 ops/sec ±0.20% (100 runs sampled) - summary ➭ observe#2 with 4 and 2 with 2 ➭ prom-client@latest x 27,597 ops/sec ±0.79% (95 runs sampled) - summary ➭ observe#2 with 2 and 2 with 4 ➭ current x 32,187 ops/sec ±0.21% (100 runs sampled) - summary ➭ observe#2 with 2 and 2 with 4 ➭ prom-client@latest x 27,513 ops/sec ±0.37% (93 runs sampled) - summary ➭ observe#6 with 2 ➭ current x 22,375 ops/sec ±0.47% (94 runs sampled) - summary ➭ observe#6 with 2 ➭ prom-client@latest x 19,161 ops/sec ±0.14% (100 runs sampled) ┌───────────────────────────────┬────────────────────┬────────────────────┐ │ histogram │ current │ prom-client@latest │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#1 with 64 │ 104381.0327549696 │ 103709.41386205897 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#2 with 8 │ 68178.1543735591 │ 53509.94862568404 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#2 with 4 and 2 with 2 │ 34169.376174278514 │ 28170.10920967872 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#2 with 2 and 2 with 4 │ 36056.509189653516 │ 28804.04102513799 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#6 with 2 │ 23359.579524196415 │ 19419.640968121184 │ └───────────────────────────────┴────────────────────┴────────────────────┘ ┌─────────────────┬───────────────────┬────────────────────┐ │ counter │ current │ prom-client@latest │ ├─────────────────┼───────────────────┼────────────────────┤ │ inc │ 59643642.79575977 │ 37023723.28415886 │ ├─────────────────┼───────────────────┼────────────────────┤ │ inc with labels │ 84761.87024308582 │ 67224.57758629428 │ └─────────────────┴───────────────────┴────────────────────┘ ┌─────────────────┬───────────────────┬────────────────────┐ │ gauge │ current │ prom-client@latest │ ├─────────────────┼───────────────────┼────────────────────┤ │ inc │ 61652788.35302279 │ 31247587.722701166 │ ├─────────────────┼───────────────────┼────────────────────┤ │ inc with labels │ 86551.57212390135 │ 64589.60038388497 │ └─────────────────┴───────────────────┴────────────────────┘ ┌───────────────────────────────┬────────────────────┬────────────────────┐ │ summary │ current │ prom-client@latest │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#1 with 64 │ 87908.71972414361 │ 94806.18075509806 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#2 with 8 │ 61909.18982275139 │ 49336.623224028765 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#2 with 4 and 2 with 2 │ 32319.8211562837 │ 27596.72566017053 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#2 with 2 and 2 with 4 │ 32187.468085238048 │ 27513.002743185254 │ ├───────────────────────────────┼────────────────────┼────────────────────┤ │ observe#6 with 2 │ 22375.38970678346 │ 19160.867264237862 │ └───────────────────────────────┴────────────────────┴────────────────────┘ ✓ histogram ➭ observe#1 with 64 is 0.6476% faster. ✓ histogram ➭ observe#2 with 8 is 27.41% faster. ✓ histogram ➭ observe#2 with 4 and 2 with 2 is 21.30% faster. ✓ histogram ➭ observe#2 with 2 and 2 with 4 is 25.18% faster. ✓ histogram ➭ observe#6 with 2 is 20.29% faster. ✓ counter ➭ inc is 61.10% faster. ✓ counter ➭ inc with labels is 26.09% faster. ✓ gauge ➭ inc is 97.30% faster. ✓ gauge ➭ inc with labels is 34.00% faster. ⚠ summary ➭ observe#1 with 64 is 7.846% acceptably slower. ✓ summary ➭ observe#2 with 8 is 25.48% faster. ✓ summary ➭ observe#2 with 4 and 2 with 2 is 17.11% faster. ✓ summary ➭ observe#2 with 2 and 2 with 4 is 16.99% faster. ✓ summary ➭ observe#6 with 2 is 16.78% faster. ```
Configuration menu - View commit details
-
Copy full SHA for ea7c08d - Browse repository at this point
Copy the full SHA ea7c08dView commit details -
Configuration menu - View commit details
-
Copy full SHA for b919fd3 - Browse repository at this point
Copy the full SHA b919fd3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3776b1d - Browse repository at this point
Copy the full SHA 3776b1dView commit details -
Configuration menu - View commit details
-
Copy full SHA for aa7ec23 - Browse repository at this point
Copy the full SHA aa7ec23View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.