oracle/graal · error · ValueError

Setting the VM option '-Dnative-image.benchmark.stages' is n

Error message

Setting the VM option '-Dnative-image.benchmark.stages' is not supported when using {self.__class__.__name__} as a dispatcher!

What it means

Some native-image benchmark dispatchers iterate over pipeline stages themselves and inject '-Dnative-image.benchmark.stages=<stage>' per stage. If the user already set that VM option explicitly, the dispatcher's injection would conflict, so _verify_stages_not_explicitly_requested() raises ValueError naming the dispatcher class.

Source

Thrown at sdk/mx.sdk/mx_sdk_benchmark.py:5858

                    if self.fork_count != 1:
                        mx.log(f"Running fork {i+1}/{self.fork_count}.")
                    yield BenchmarkExecutionConfiguration(supported_benchmarks, self.state.mx_benchmark_args, JMHNativeImageDispatcher._inject_stage_arg(suite_args, str(StageName.RUN)), ForkInfo(i, self.fork_count))

    def _get_pre_run_stages(self) -> list[Stage]:
        vm = self.suite.get_vm_registry().get_vm_from_suite_args(self.state.bm_suite_args)
        effective_stages, _ = vm.prepare_stages(self.suite, self.state.bm_suite_args)
        return [stage for stage in effective_stages if stage.stage_name != StageName.RUN]

    @staticmethod
    def _inject_stage_arg(bm_suite_args: list[str], stage_name: str) -> list[str]:
        stage = Stage.from_string(stage_name)
        return [f"-Dnative-image.benchmark.stages={stage}"] + bm_suite_args

    def _verify_stages_not_explicitly_requested(self):
        vm_args = self.state.suite.vmArgs(self.state.bm_suite_args)
        if len(parse_prefixed_args("-Dnative-image.benchmark.stages=", vm_args)) > 0:
            msg = f"Setting the VM option '-Dnative-image.benchmark.stages' is not supported when using {self.__class__.__name__} as a dispatcher!"
            raise ValueError(msg)

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Remove -Dnative-image.benchmark.stages=... from your VM options and let the dispatcher select stages.
  2. If you need stage selection, use the dispatcher's own stage-selection mechanism (e.g. its stage filter arguments) instead of the VM option.
  3. Search your full command line, including --J/@-file args, for the property; it is parsed out of vmArgs.

Example fix

# before
mx benchmark ... -- -Dnative-image.benchmark.stages=run   # dispatcher also sets it

# after
mx benchmark ...   # dispatcher injects the stage property per stage
Defensive patterns

Strategy: validation

Validate before calling

from mx_sdk_benchmark import parse_prefixed_args
hits = parse_prefixed_args("-Dnative-image.benchmark.stages=", vm_args)
assert not hits, "drop the explicit stages property; the dispatcher sets it per stage"

Prevention

When it happens

Trigger: Combining a multi-stage dispatcher (e.g. one that runs each native-image benchmark stage separately) with an explicit -Dnative-image.benchmark.stages=... in the VM args of the benchmark command.

Common situations: Reusing a command line written for the non-dispatcher path; CI configs that hard-code the stages property.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/1f83018d83527b2b. Report an issue: GitHub.