Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Minify the startup snapshot script with terser #17926
I was just looking at a heap snapshot in Atom and I noticed something striking - over a third of the memory allocated on V8's heap is due to a single
In particular, the script retains a reference to its source code as a string, which consumes around 45MB of RAM:
In addition, the script maintains an array of
In this PR, I minify the startup script that
When I compute a heap snapshot after minification, the startup script's
To get a sense of the overall impact, I rebuilt
The minification step does take some time. It adds 10 - 20 seconds to the build.
smashwilson left a comment
One question: I see that we aren't generated sourcemaps for the minified code. Does this result in mangled stacktraces? An inline sourcemap would defeat the purpose of the minification I'm sure... but maybe one saved in a separate file wouldn't be loaded unless you actually needed it... ?
I've actually wondered if we could get away with not shipping source at all by default - relying on the snapshot for distribution of core and bundled packages. Maybe bundling it separately and downloading it on demand so that people could debug. It would really slim down our app download. It's probably not worth it though
Yeah, great points about stack traces and source maps. We’d need to do that before merging this. Hopefully it won’t negate the memory savings.
I think the only reason we include the source in the bundle is so you can run Atom in dev mode for debugging without having the source checked out. Not sure how many people do that though.
Actually, I don't think we need to do anything for stack traces. Here's an example error that I produced by manually breaking my editor from the dev tools:
Since property names are not mangled by default, and I've disabled mangling of class names, everything is just as clear as before. Even before this change, the line numbers weren't really useful because they were referring to the concatenated
One other drawback: the dev tools becomes unresponsive for about 10 seconds if you try to open the
It looks like it does reduce the size of
I agree. The source code is not very useful anyway in the form that we ship it. If people really want to debug Atom's bundled code, they pretty much need to clone and build Atom anyway. I'm inclined to attack this in a separate PR, but I do think it's worth doing.