CPU Usage Optimizations?



  • Do the devs have any tips about how to reduce cpu usage?

    Does the size of our js files affect cpu usage very much? (like, are they parsed every tick?) If this is so, would "minifying" our source files reduce CPU usage?

    Any other hints or tips about CPU usage?



  • I messed around with using c++ with emscripten, and it produced javascript files that were 800kb or so (300 when minified). It would frequently spend about 100 cpu just loading the script (without calling any functions at all), but I did not notice any difference minified vs not (there might've been though).
    It seems like they're using V8 javascript engine, since performance is similar to node.js and Chrome, and there is definitely no support for asm.js.

    It seems to me like there is significant overhead with functions being constantly recompiled. I worry that by the time the JIT gets warmed up the tick is already over and it all gets recompiled the next tick.

    Right now I'm using LLJS and using ArrayBuffers for some stuff. The performance is good but there is significant overhead with serializing data into Memory because it is converted to json for storage and ArrayBuffer is not supported, and converting to utf8 string is expensive.
    I would be quite happy if Memory supported ArrayBuffer.

    Honestly I think they could improve the "caching" of scripts or otherwise let the JIT keep compiled functions between ticks, but it's possible their infrastructure prevents this. Or they might already do it and I'm reading things wrong, it's hard to profile code running on their servers.