Skip to content

Ruby ergonomics #1

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

Closed
chrisseaton opened this issue Apr 23, 2022 · 5 comments
Closed

Ruby ergonomics #1

chrisseaton opened this issue Apr 23, 2022 · 5 comments

Comments

@chrisseaton
Copy link
Collaborator

There's some very low-hanging fruit for basic Ruby ergonomics with MMTk. I'd like to get approval for these but then reserve them for some beginners that I'd like to encourage to try the project.

Version flag

When you run Ruby with one of the JITs you get a flag in --version so that it's really obvious in error messages. We should do the same for MMTk, and print the plan in use.

% ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]
% ruby --jit -v 
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) +MJIT [arm64-darwin21]

We could add:

% MMTK_PLAN=MarkSweep ruby -v 
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) +MMTk(MarkSweep) [arm64-darwin21]

MMTk command-line flag

It'd be great if we could have MMTk as a run-time option. Can we do that? It'd be so much more convenient for shipping and experiments.

% ruby --mmtk ...

Plan command-line flag

Should it be possible to set the plan using a command-line flag? That's more common for these kind of options in Ruby than an environment variable.

% ruby --mmtk-plan=MarkSweep ...

Default heap size

Is there a default heap size we should use? What's the default if you don't set one? Can we calculate a default from system parameters?

Basic GC.stat support

What should GC.stat show for MMTk and the various plans? Can we get some basic stats out of MarkSweep and None already?

@qinsoon
Copy link
Member

qinsoon commented Apr 24, 2022

MMTk command-line flag

It'd be great if we could have MMTk as a run-time option. Can we do that? It'd be so much more convenient for shipping and experiments.

% ruby --mmtk ...

That is possible. Most MMTk options can be set through command line arguments. And it is the preferred way to set MMTk options.

Plan command-line flag

Should it be possible to set the plan using a command-line flag? That's more common for these kind of options in Ruby than an environment variable.

% ruby --mmtk-plan=MarkSweep ...

Unfortunately plan is one of the options that currently cannot be set through command line arguments. There are one or two options that MMTk uses when MMTk is instantiated which happens before MMTk can accept command line arguments. Some refactoring is needed on this in MMTk core.

@chrisseaton
Copy link
Collaborator Author

For the version string we've done ruby/ruby#5872 as preparatory work, and have a branch to actually add +MMTk. Adding the plan is possibly blocked by mmtk/mmtk-core#583.

@chrisseaton
Copy link
Collaborator Author

chrisseaton commented Jul 1, 2022

Version string done as mmtk/ruby#1.

@chrisseaton
Copy link
Collaborator Author

chrisseaton commented Jul 25, 2022

Heap size flag done as mmtk/ruby#9.

This just leaves a runtime flag --mmtk to do, which is work-in-progress.

@chrisseaton
Copy link
Collaborator Author

Runtime flag done as mmtk/ruby#14, so that's all ergonomics done now.

My next step is going to be checking the diff against upstream and seeing if I can minimise it a bit. We were doing some initial benchmarking, but with the understanding that MarkSweep uses malloc we'll pause that as we understand the performance difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants