sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

Reducing code-size for web version

Open hfhchan opened this issue 9 years ago • 3 comments

Currently even the minified version is a whopping 2.04 MB which is a rather heavy even when gzipped. Looking through the code, I noticed that Emscripten's canvas, SDL audio and requestAnimationFrame are included in the minified output, which are obviously not used by SQLite.

When compiling only for browser, ENVIRONMENT_IS_NODE and ENVIRONMENT_IS_SHELL would be false and could be dead-code eliminated. Also, the filesystem and TTY also takes out a substantial chunk of code which could be unnecessary. _sysconf is also ever called with 30 so it could be aggressively inlined.

I wonder if there are options to set which could reduce the code size?

hfhchan avatar Aug 29 '16 07:08 hfhchan

Recent emscripten versions have improvements here, so an update might help. There are also a bunch of options one could try.

kripken avatar Aug 29 '16 15:08 kripken

That's funny that the compiled version overwhelmingly uses right shift (>>) and sometimes even on 0 (>>0).

avesus avatar Sep 02 '16 07:09 avesus

I think right shift is for fast division, and is especially useful for pointer arithmetic. Nothing abnormal here.

But I agree this project HAS TO be recompiled with a recent version of emscripten.

lovasoa avatar Sep 02 '16 19:09 lovasoa