Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fpotter opened this issue Nov 8, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@fpotter
Copy link

fpotter commented Nov 8, 2024

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.

@fpotter fpotter added the enhancement New feature or request label Nov 8, 2024
@jbedard jbedard self-assigned this Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants