Skip to content

[FR]: Add support for customizing resource_set info for rules_js build actions. #2015

@fpotter

Description

@fpotter

What is the current behavior?

The bazel scheduler assumes all build actions take 1 CPU and 250MB of RAM by default. This leads to Bazel over-scheduling memory or CPU hungry build actions.

In our case, we have several Vite build actions that are running in parallel, many with --max-old-space-size=16384. When we're unlucky, enough of these will be scheduled in parallel and Bazel will OOM crash with:

Server terminated abruptly (error code: 14, error message: 'Socket closed', log file: '/mnt/ephemeral/output/lattice-control-app/__main__/server/jvm.out')

Describe the feature

In our repo, we're currently bundling several large Vite applications in parallel. The bundling step is the most memory intensive part of our build.

Similar to aspect-build/rules_ts#569, we'd like the ability to specify resource_set or similar in rules_js build actions. e.g.,

    vite_bin.vite(
        name = "build",
        srcs = [
          # sources
        ],  
        args = [
            "build",
            "--config",
            "vite.config.mjs",
            "-m",
            "production",
        ],
        chdir = native.package_name(),
        env = {
            "NODE_OPTIONS": " ".join([
                "--max-old-space-size={size}".format(size = build_max_old_space_size_gb * 1024),
            ]),
        },
        out_dirs = [
            "build",
        ],
        silent_on_success = False,
        visibility = ["//visibility:public"],
        resource_set = "mem_8g",  # <<<<<<<<<<<<<
        **kwargs
    )

There's maybe an opportunity here to couple resource_set and --max-old-space-size, as you're likely bumping these together.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions