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

Repeated require/freshRequire leak memory and prevent effective just-in-time compilation #145

Open
smarr opened this issue Mar 25, 2024 · 0 comments

Comments

@smarr
Copy link

smarr commented Mar 25, 2024

This is more an attempt to document the issue (there's a change here that others might want to try though: smarr@66b8e9b).

I assume ChartjsNodeCanvas is designed to ensure perfect isolation of plugins, and supporting all kind of Chart.js plugins. To achieve this, I assume, the idea was to just require plugins and other code separately to ensure complete isolation.

However, this also leads to high memory overhead and additional costs such as requiring extra compilation by Node.js for every single canvas. So, creating a canvas is prohibitively expensive, perhaps more so that the documentation suggests already. The other problem is that requiring large chunks of code again and again leaks memory for the code, and then for the native compilation. Node.js doesn't really like this.

In my fork, I stripped out all require()/freshRequire() calls since I don't need the support for legacy plugins and plugin isolation. So, that's not something I can generally recommend. However, it comes at major performance gains of cutting chart render time by 50-80% in my case.

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

No branches or pull requests

1 participant