Giter Club home page Giter Club logo

Comments (4)

colinhacks avatar colinhacks commented on June 19, 2024 4

Thanks for the effort you put into this benchmark! I'm broadly aware of this and am working on solutions in Zod 4. There are some very obvious performance in Zod's current parsing pipeline that unfortunately will require breaking changes to fix.

I'll report back with updated performance numbers against this benchmark once Zod 4 is nearing beta.

from zod.

jussisaurio avatar jussisaurio commented on June 19, 2024 2

^I made a POC of not using ctx.async and instead detecting Promises during parsing. Here's the branch https://github.com/jussisaurio/zod/pull/1/files which currently is based on my other zod perf PR (#3487)

Results using your benchmark @warflash :

[email protected]:

Benchmarking with 1000 elements
Validation time sync: 25.703ms
Validation time async: 61.169ms

Benchmarking with 10000 elements
Validation time sync: 110.733ms
Validation time async: 641.032ms

Benchmarking with 50000 elements
Validation time sync: 592.054ms
Validation time async: 4.608s

Benchmarking with 100000 elements
Validation time sync: 1.541s
Validation time async: 13.151s

branch:

Benchmarking with 1000 elements
Validation time sync: 20.666ms
Validation time async: 11.56ms

Benchmarking with 10000 elements
Validation time sync: 113.841ms
Validation time async: 100.013ms

Benchmarking with 50000 elements
Validation time sync: 510.81ms
Validation time async: 512.89ms

Benchmarking with 100000 elements
Validation time sync: 1.056s
Validation time async: 1.188s

The reason sync/async are almost the same in the branch is that it doesn't extra wrap any promises. A more comprehensive benchmark would include stuff like async refines to see what the impact is

from zod.

warflash avatar warflash commented on June 19, 2024

Great, that sounds very nice!
Appreciate the reply and really looking forward to trying out the v4 beta then to see how it performs against our production ingests 😊

from zod.

jussisaurio avatar jussisaurio commented on June 19, 2024

Wonder if it would work to get rid of ctx.async and just handle all results from _parse() as potentially async (i.e. check whether the return value is a Promise. Currently there seems to be a lot of potentially unnecessary Promise wrapping just based on ctx.async

from zod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.