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

DART_VM_OPTIONS for self-executables not working! #55767

Closed
gmpassos opened this issue May 18, 2024 · 8 comments
Closed

DART_VM_OPTIONS for self-executables not working! #55767

gmpassos opened this issue May 18, 2024 · 8 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team

Comments

@gmpassos
Copy link
Contributor

As mentioned on README, Dart 3.4.0 supports DART_VM_OPTIONS for self-executables:

README.md:

...
### Dart Runtime

- Dart VM flags and options can now be provided to any executable generated
  using `dart compile exe` via the `DART_VM_OPTIONS` environment variable.
  `DART_VM_OPTIONS` should be set to a list of comma-separated flags and options
  with no whitespace. Options that allow for multiple values to be provided as
  comma-separated values are not supported (e.g.,
  `--timeline-streams=Dart,GC,Compiler`).

  Example of a valid `DART_VM_OPTIONS` environment variable:

   DART_VM_OPTIONS=--random_seed=42,--verbose_gc

...

Example:

foo.dart:

void main(List<String> args) {
  print("FOO>> args: $args");
}

run-foo.sh:

#!/bin/bash

dart compile exe foo.dart

export DART_VM_OPTIONS=--random_seed=42,--verbose_gc
echo "DART_VM_OPTIONS: $DART_VM_OPTIONS"

echo "Running executable:"
./foo.exe

Output of ./run-foo.sh:

Generated: /private/tmp/dart-test-foo/foo.exe
DART_VM_OPTIONS: --random_seed=42,--verbose_gc
Running executable:
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]

Executes the Dart script <dart-script-file> with the given list of <script-arguments>.

Common VM flags:
--help or -h
  Display this message (add -v or --verbose for information about
  all VM options).
--packages=<path>
  Where to find a package spec file.
--define=<key>=<value> or -D<key>=<value>
  Define an environment declaration. To specify multiple declarations,
  use multiple instances of this option.
--snapshot-kind=<snapshot_kind>
--snapshot=<file_name>
  These snapshot options are used to generate a snapshot of the loaded
  Dart script:
    <snapshot-kind> controls the kind of snapshot, it could be
                    kernel(default) or app-jit
    <file_name> specifies the file into which the snapshot is written
--version
  Print the SDK version.

For some reason it's always showing the dart CLI help message.


dart --version:

Dart SDK version: 3.4.0 (stable) (Mon May 6 07:59:58 2024 -0700) on "macos_x64"

@gmpassos
Copy link
Contributor Author

FYI: @bkonyi

@lrhn lrhn added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label May 19, 2024
@bkonyi
Copy link
Contributor

bkonyi commented May 22, 2024

Thanks for the heads up @gmpassos. I'm able to reproduce and it looks like there was some oversights in the implementation that wasn't caught by testing. I have a fix up for review here.

@bkonyi bkonyi self-assigned this May 22, 2024
@bkonyi bkonyi added P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team labels May 22, 2024
@gmpassos
Copy link
Contributor Author

... I have a fix up for review here.

Please add documentation for DART_VM_OPTIONS, especially for self-executables. This is not documented anywhere.

@bkonyi
Copy link
Contributor

bkonyi commented May 22, 2024

Cherrypick request has been filed here: #55818.

@bkonyi
Copy link
Contributor

bkonyi commented May 22, 2024

Please add documentation for DART_VM_OPTIONS, especially for self-executables. This is not documented anywhere.

There's not any obvious spot to put this on the website since it's relatively niche functionality, but I've added documentation in the SDK that should make this a bit easier to discover: https://dart-review.googlesource.com/c/sdk/+/367800

@gmpassos
Copy link
Contributor Author

gmpassos commented May 22, 2024

... it's relatively niche functionality.

The default max heap size is 30GB:

const intptr_t kDefaultMaxOldGenHeapSize = (kWordSize <= 4) ? 1536 : 30720;

IMHO, every self-executable in production should define its memory limit, since running any application with a heap limit higher than the available memory is a recipe for disaster. Since the only way to define the max heap size in a self-executable is by using DART_VM_OPTIONS, this shouldn't be treated as a hidden property.

copybara-service bot pushed a commit that referenced this issue May 30, 2024
… of help message

Fixes #55767

TEST=pkg/dartdev/test/commands/compile_test.dart

Change-Id: I6a773acbd9fc21c086fc459c7cb983ea1ff11fcd
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/367720
Cherry-pick-request: #55818
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367721
Reviewed-by: Siva Annamalai <[email protected]>
Commit-Queue: Ben Konyi <[email protected]>
@a-siva
Copy link
Contributor

a-siva commented Jun 10, 2024

I believe this can be closed ?

@bkonyi
Copy link
Contributor

bkonyi commented Jun 10, 2024

I believe this can be closed ?

It's already closed :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team
Projects
None yet
Development

No branches or pull requests

4 participants