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

perf: reduce function calls for shallower stacks #1022

Merged
merged 1 commit into from
Aug 28, 2020
Merged

perf: reduce function calls for shallower stacks #1022

merged 1 commit into from
Aug 28, 2020

Conversation

jquense
Copy link
Owner

@jquense jquense commented Aug 28, 2020

starts to address #1017 bringing the benchmark for sync and async within striking distance of joi at least


export default function createValidation(config) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

most wins due to simplifying this call by reducing indirection and inlining helpers

import ValidationError from '../ValidationError';
import { once } from './async';

export default function runTests(options, cb) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

more big wins here, by making this function less clear with the loop but much shallower

@JaneJeon
Copy link

JaneJeon commented Aug 28, 2020

This is excellent! I'm getting 96k req/s with the synchronous implementation (vs. joi's 157k) - well within striking range of joi (50%), and fast enough to not be the bottleneck for either express or fastify! Now when my servers run fast, I truly have no excuse but my crappy code xD

I'd love to see further work on this, and I'm willing to even contribute performance regression tests if necessary. Thanks for doing this!

@jquense
Copy link
Owner Author

jquense commented Aug 28, 2020

and I'm willing to even contribute performance regression tests if necessary

That would be excellent and appreciated, having some benchmarks in the repo would be really helpful for tracking this stuff longer term. Doesn't need to be fancy just some numbers for yup to compare new versions against

@JaneJeon
Copy link

will get on it after work!

@jquense jquense merged commit 01da7e1 into master Aug 28, 2020
@jquense jquense deleted the hack branch August 28, 2020 13:27
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.

2 participants