rules_swc icon indicating copy to clipboard operation
rules_swc copied to clipboard

Bazel OOM when using swc rules for a large repo

Open ewianda opened this issue 3 years ago • 2 comments

I am trying to migrate a large code base to using swc transpiler and I keep getting

FATAL: bazel ran out of memory and crashed. Printing stack trace:
java.lang.OutOfMemoryError: Java heap space

The only difference I see in my config is the use of --enable_runfiles . I have looked into the code to understand why this flag is needed and if it is possible to turn it off.

ewianda avatar Aug 25 '22 12:08 ewianda

How much memory does the machine have to work with and how many typescript files do you have in your repository?

Using swc as the transpiler creates one target per typescript file which can make for a very large graph.

gregmagolan avatar Oct 12 '22 12:10 gregmagolan

We have 32GB machine and a repository of 1200 typescript files. I even configure the bazel to have more memory with --host_jvm_args=-Xmx16g and no luck.

I also noticed that --enable_runfiles is not not required.

ewianda avatar Oct 18 '22 21:10 ewianda

I wonder if the use of rules_js contributed to the large amount of starlark heap used. The next release includes #57 which might help.

I think we need the profile from bazel. @ewianda if you're still able to repro after the next release here, would you mind following https://bazel.build/rules/performance#memory-profiling to get an output of bazel dump --rules and a prof.gz that we can inspect?

alexeagle avatar Jan 07 '23 00:01 alexeagle

Sorry, @alexeagle and @gregmagolan I should have reported back earlier.

This error went away after we migrated from rules_nodejs to rules_js.

ewianda avatar Jan 10 '23 21:01 ewianda

Awesome thank you for confirming!

alexeagle avatar Jan 12 '23 04:01 alexeagle