Coder Social home page Coder Social logo

Comments (9)

mcollina avatar mcollina commented on May 24, 2024 1

Essentially those are the kind of logic we might want to consider.

Just run a flamegraph against https://github.com/mercurius-js/cache/tree/main/bench and you'll see the bottleneck.

from async-cache-dedupe.

zbo14 avatar zbo14 commented on May 24, 2024 1

another option would be to modify the serialize() function so it constructs/returns a string instead of an object that's later stringified. Not sure if this is feasible though.

@mcollina does the following screenshot corroborate your findings?

_home_zach_Projects_cache_1576762 0x_flamegraph html (1)

from async-cache-dedupe.

mcollina avatar mcollina commented on May 24, 2024 1

Also, mercurius-js/cache is still using v0.5.0 of async-cache-dedupe. Perhaps we can revisit when it has the newer code?

It has been updated this week.

from async-cache-dedupe.

simoneb avatar simoneb commented on May 24, 2024

What about this one? https://github.com/epoberezkin/fast-json-stable-stringify

from async-cache-dedupe.

mcollina avatar mcollina commented on May 24, 2024

See the benchmarks at https://github.com/BridgeAR/safe-stable-stringify#performance--benchmarks

from async-cache-dedupe.

zbo14 avatar zbo14 commented on May 24, 2024

@mcollina any way you can share the analysis or provide instructions to repro?

safe-stable-stringify seems pretty fast compared to other stringify options and v8 serialization. We could try a different approach, e.g. cache array lengths and lists of top-level object keys as well. This might help detect cache misses more quickly before stringifying giant nested objects. I'm not sure this addresses a cause of the bottleneck you mentioned though.

from async-cache-dedupe.

mcollina avatar mcollina commented on May 24, 2024

Yes, exactly. It gets worse as the parameters size grows.

from async-cache-dedupe.

zbo14 avatar zbo14 commented on May 24, 2024

I've tried using yieldable-json and worker threads with pinscina for stringification. Both approaches under-perform safe-stable-stringify. Unless there are other benchmarks indicating that safe-stable-stringify is a serious performance concern, perhaps it makes sense to optimize mercurius cache serialization instead?

Also, mercurius-js/cache is still using v0.5.0 of async-cache-dedupe. Perhaps we can revisit when it has the newer code?

from async-cache-dedupe.

mcollina avatar mcollina commented on May 24, 2024

I'll close this for now./

from async-cache-dedupe.

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.