Code-server: optimize memory usage

Created on 8 Mar 2019  路  7Comments  路  Source: cdr/code-server

Most helpful comment

@kylecarbs So based on my testing and some further research, here's what I can suggest to make our consumption low

V8 by default in nbin should be JIT-Less

The problem with V8's way of dealing with JITed code takes a lot of memory - hence why it can't run on memory-limited environments properly. Google did a trick on V8 by going JIT-less. The way V8 does this is directly using the Ignition interpreter. This improved Chrome's performance in Mobile by around 20% according to V8's Blog.

Refactor the Forking process

It seems extension host contributes to most of code-server's memory. We should do optimizations on the forking process. It seems to fork too much which is considered not okay.

I suggest looking at Theia's extension manager to help with our patch.

Use Node-ChakraCore

This should be considered last resort. ChakraCore is known to work on mobile without much modification and overhead, hence its a good way to consider using ChakraCore. A version of node exists for this. The downside is on Raspberry Pi Zeros, Chakra won't be able to take advantage of its threaded implementation.

All 7 comments

This will require a significant amount of refactoring in the way we fork processes. Will likely require a custom binary packaging system.

a more likely patch as well is to tell V8 to go JITLess and use Ignition, which should tell the engine to no longer allocate a stack for compiling bytecode and instead use the interpreter. This approach has been seen to improve performance so I believe we can set this as well

@kylecarbs So based on my testing and some further research, here's what I can suggest to make our consumption low

V8 by default in nbin should be JIT-Less

The problem with V8's way of dealing with JITed code takes a lot of memory - hence why it can't run on memory-limited environments properly. Google did a trick on V8 by going JIT-less. The way V8 does this is directly using the Ignition interpreter. This improved Chrome's performance in Mobile by around 20% according to V8's Blog.

Refactor the Forking process

It seems extension host contributes to most of code-server's memory. We should do optimizations on the forking process. It seems to fork too much which is considered not okay.

I suggest looking at Theia's extension manager to help with our patch.

Use Node-ChakraCore

This should be considered last resort. ChakraCore is known to work on mobile without much modification and overhead, hence its a good way to consider using ChakraCore. A version of node exists for this. The downside is on Raspberry Pi Zeros, Chakra won't be able to take advantage of its threaded implementation.

@sr229 how can we compile nbin to be JIT-less?

@kylecarbs Refer to nodejs/node#26758

Left some comments as well for possible flags to include for performance increase in #795

We managed to fix this in GH-857 (158M init, 256M with 3-5 extensions) so I'm writing this off as fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tecosaur picture tecosaur  路  3Comments

pchecinski picture pchecinski  路  3Comments

grant picture grant  路  3Comments

RealSlimMahdi picture RealSlimMahdi  路  3Comments

korzq picture korzq  路  3Comments