piscina
piscina copied to clipboard
Reduce install/bundle size
Hello folks, I'm the tinypool (the 25kb fork of piscina) creator, and we've been talking about how to reduce the piscina's install size on Twitter. I hope my findings benefit you!
Bundling & Minifying
In tinypool, I don't bundle any dependency since there's no dependency for tinypool, but it seems that we can remove some additional files (of piscina's dependencies by bundling them). You can see those useless files included in the install size here.
https://unpkg.com/browse/[email protected]/ (src, test) https://unpkg.com/browse/[email protected]/ (benchmark, src, test) https://unpkg.com/browse/[email protected]/ (test) https://unpkg.com/browse/[email protected]/ (test, src, benchmark, ...)
Removing dependencies
In tinypool, we remove eventemitter-asyncresource (copying its minimal content & dropping other files) & hdr-histogram since we didn't need the last one. Still, I guess piscina can't do that; utilization is one of the good features of piscina (in @vitest-dev we didn't need it). But as it was mentioned in Twitter, node 14 already afford that for us, so I guess by dropping node 12, we can reduce a significant portion of the install size!
https://twitter.com/matteocollina/status/1471828739537391623 https://twitter.com/jasnell/status/1471831611108839425
Thanks to the Piscina team for reaching out & giving us the opportunity + to those who helped me maintain tinypool, @trysound @vitest-dev
It's entirely likely that we can drop the dependency on hdr-histogram in a new major release and depend directly on the createHistogram() function in Node.js. There are some API differences there, however, so I'll need to investigate. If it does look like that's possible, however, that will be a significant reduction.
I'd also like to see if we can get eventemitter-asyncresource added to Node.js as an option. It's too much of a performance hit for us to make all EventEmitter
instances work with async resource tracking but having the option built in to core makes the most sense long term.
Yea, dropping the hdr-histogram seems reasonable! I am waiting for the significant reduction.
And if you need help in the process, I'm happy to help! Thanks for the consideration!
It'll take a while before we can rely on it being available in all supported versions, but https://github.com/nodejs/node/pull/41246 merges one of the dependencies here into node.js core.
That's a good change! Thanks for that!
tinypool
uses it internally, so it doesn't get that much of dependencies!
With Node.js 12 being EOL, we can drop hdr-histogram-js. Is that correct?