hyparam / hyperparam-cli

Hyperparam local dataset viewer
https://hyperparam.app
MIT License
2 stars 0 forks source link

optimize the size of the bundles? #46

Open severo opened 3 days ago

severo commented 3 days ago

The bundles are too big!

utils:

dist/index.es.min.js  925.19 kB │ gzip: 284.48 kB │ map: 2,073.04 kB
dist/index.umd.min.js  659.19 kB │ gzip: 256.25 kB │ map: 2,014.01 kB

components:

dist/index.es.min.js  958.91 kB │ gzip: 293.95 kB │ map: 1,679.42 kB
dist/index.umd.min.js  684.28 kB │ gzip: 265.02 kB │ map: 1,620.09 kB

hightable-demo:

dist/index.html                   0.66 kB │ gzip:  0.42 kB
dist/assets/index-V1S-DhZj.css    6.36 kB │ gzip:  2.08 kB
dist/assets/index-O27HHpO3.js   152.21 kB │ gzip: 49.64 kB

hyparquet-demo

dist/index.html                         1.18 kB │ gzip:   0.57 kB
dist/assets/huggingface-Df0G9hpA.svg    5.91 kB │ gzip:   2.63 kB
dist/assets/hyparquet-Cs3XnChP.mp3     24.62 kB
dist/assets/index-CHa8szko.css         10.88 kB │ gzip:   3.36 kB
dist/assets/index-D_yEg-np.js         509.54 kB │ gzip: 213.44 kB

(!) Some chunks are larger than 500 kB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.

cli:

-rw-rw-r-- 1 severo severo 494K Nov 15 23:33 app.min.js
-rw-rw-r-- 1 severo severo 1.6M Nov 15 23:33 app.min.js.map
platypii commented 2 days ago

A lot of that is react?

cd packages/utils
npx vite-bundle-visualizer

Screenshot at 2024-11-15 16-11-08

Without react it's much smaller. I suspect we should be excluding react from components and utils bundles? Maybe by making it a peer dependency explicitly?

Without react it would look more like this, with most of the size in hyparquet-compressors

Screenshot at 2024-11-15 16-03-32

A good chunk of the remaining is for hyparquet-compressors which has decompressors for brotli which unfortunately have pretty big lookup table which doesn't compress. We could potentially load async when needed, since most parquet files use snappy compression and others are rare.

severo commented 2 days ago

Awesome analysis! It will be easier to fix the issue.