Skip to content

Sandboxed bazel builds with emsdk are slow #1026

Closed

Description

@jfirebaugh

I noticed that a wasm_cc_binary target subjectively felt a lot slower to compile than its cc_binary equivalent. During the build, the Bazel java process was consuming 300-400% CPU. I used the --profile flag and it showed that almost all the time was being spent in sandbox.createFileSystem and sandbox.delete. So I used --sandbox_debug and poked into a few of the resulting directories. Each contains 17-18k symlinks, including the following:

  • An emscripten_npm_mac tree containing ~600 directories and ~9k symlinks.
  • An emscripten_bin_mac tree containing ~500 directories and ~8k symlinks.

emsdk is configured in my workspace as follows:

http_archive(
    name = "emsdk",
    sha256 = "7dc13d967705582e11ff62ae143425dbc63c38372f1a1b14f0cb681fda413714",
    strip_prefix = "emsdk-3.1.4/bazel",
    url = "https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.4.tar.gz",
    patch_args = ["-p2"],
    patch_tool = "patch",
    patches = [
        "//bazel/patches:0001-Fix-https-github.com-emscripten-core-emsdk-issues-10.patch",
    ],
)

load("@emsdk//:deps.bzl", emsdk_deps = "deps")
emsdk_deps()

load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
emsdk_emscripten_deps(emscripten_version = "3.1.4")

Is there any way to improve / optimize this?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions