GithubHelp home page GithubHelp logo

Comments (6)

veltman avatar veltman commented on May 23, 2024

A few initial impressions on this:

  • The rendering code takes a trivial amount of time (a few ms per frame) - almost all of the time is spent on writing the rendered canvas to disk.
  • There's no real difference between a pngStream and using synchronous .toBuffer() in terms of performance.
  • Using an asynchronous .toBuffer() is about 4x faster, but means that we can't render in parallel on the same canvas. This is probably fine
  • Adding compression as a second argument would probably speed it up some more.

One possibility is to create a new Canvas for every frame, rather than a shared one. This would speed up the I/O a lot, but add some overhead for that. The smarter option would probably work is to create a pool of n canvases, where n is the max concurrency, and share them that way.

from audiogram.

veltman avatar veltman commented on May 23, 2024

Tried this with a pool of canvases and async toBuffer() and rendering time is about 4x lower than previously. Will have to test this elsewhere, it may run into memory issues. May also involve refactoring the renderer/ code a bit.

from audiogram.

veltman avatar veltman commented on May 23, 2024

Have a seemingly-working version of this on the refactor branch.

from audiogram.

veltman avatar veltman commented on May 23, 2024

No apparent memory issues, but the performance benefits seem to be contingent on having multiple cores.

from audiogram.

veltman avatar veltman commented on May 23, 2024

Per the above, might want to set the parallelism based on the value of os.cpus(), though it's not clear whether it would hurt anything.

from audiogram.

veltman avatar veltman commented on May 23, 2024

Merged this to master. Should see performance improvements on a multicore machine.

from audiogram.

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.