ruby-changes:68977
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:33 +0900 (JST)
Subject: [ruby-changes:68977] b415ceb92e (master): Increase default YJIT call threshold to 10. Add exec mem size arg. (#52)
https://git.ruby-lang.org/ruby.git/commit/?id=b415ceb92e From b415ceb92e464011a9326c9cb5e15a84c39da330 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maximechevalierb@g...> Date: Wed, 26 May 2021 15:25:50 -0400 Subject: Increase default YJIT call threshold to 10. Add exec mem size arg. (#52) --- README.md | 13 +++++++------ ruby.c | 5 ++++- yjit.h | 3 +++ yjit_codegen.c | 2 +- yjit_iface.c | 7 +++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d55ddca747..03d02c634d 100644 --- a/README.md +++ b/README.md @@ -82,11 +82,12 @@ The machine code generated for a given method can be printed by adding `puts YJI https://github.com/ruby/ruby/blob/trunk/README.md#L82 YJIT supports all command-line options supported by upstream CRuby, but also adds a few YJIT-specific options: - - `--disable-yjit`: turn off YJIT (enabled by default) - - `--yjit-stats`: produce statistics after the execution of a program (must compile with `cppflags=-DRUBY_DEBUG` to use this) - - `--yjit-call-threshold=N`: number of calls after which YJIT begins to compile a function (default 2) - - `--yjit-version-limit=N`: maximum number of versions to generate per basic block (default 4) - - `--yjit-greedy-versioning`: greedy versioning mode (disabled by default, may increase code size) +- `--disable-yjit`: turn off YJIT (enabled by default) +- `--yjit-stats`: produce statistics after the execution of a program (must compile with `cppflags=-DRUBY_DEBUG` to use this) +- `--yjit-exec-mem-size=N`: size of the executable memory block to allocate (default 256 MiB) +- `--yjit-call-threshold=N`: number of calls after which YJIT begins to compile a function (default 2) +- `--yjit-version-limit=N`: maximum number of versions to generate per basic block (default 4) +- `--yjit-greedy-versioning`: greedy versioning mode (disabled by default, may increase code size) ### Benchmarking @@ -142,7 +143,7 @@ The core of CRuby's interpreter logic is found in: https://github.com/ruby/ruby/blob/trunk/README.md#L143 - `vm_insnshelper.c`: logic used by Ruby's bytecode instructions - `vm_exec.c`: Ruby interpreter loop -### Coding & Debugging Protips +### Coding & Debugging Protips There are 3 test suites: - `make btest` (see `/bootstraptest`) diff --git a/ruby.c b/ruby.c index 8ac7844375..c7bc2ad7a8 100644 --- a/ruby.c +++ b/ruby.c @@ -1036,7 +1036,10 @@ setup_yjit_options(const char *s, struct rb_yjit_options *yjit_opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1036 if (*s != '-') return; const size_t l = strlen(++s); - if (opt_match_arg(s, l, "call-threshold")) { + if (opt_match_arg(s, l, "exec-mem-size")) { + yjit_opt->exec_mem_size = atoi(s + 1); + } + else if (opt_match_arg(s, l, "call-threshold")) { yjit_opt->call_threshold = atoi(s + 1); } else if (opt_match_arg(s, l, "version-limit")) { diff --git a/yjit.h b/yjit.h index 3359a51435..1969ced260 100644 --- a/yjit.h +++ b/yjit.h @@ -33,6 +33,9 @@ struct rb_yjit_options { https://github.com/ruby/ruby/blob/trunk/yjit.h#L33 // Enable compilation with YJIT bool yjit_enabled; + // Size of the executable memory block to allocate in MiB + unsigned exec_mem_size; + // Number of method calls after which to start generating code // Threshold==1 means compile on first execution unsigned call_threshold; diff --git a/yjit_codegen.c b/yjit_codegen.c index 791095efb7..6b32b4e4e7 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -2792,7 +2792,7 @@ void https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L2792 yjit_init_codegen(void) { // Initialize the code blocks - uint32_t mem_size = 128 * 1024 * 1024; + uint32_t mem_size = rb_yjit_opts.exec_mem_size * 1024 * 1024; uint8_t *mem_block = alloc_exec_mem(mem_size); cb = █ diff --git a/yjit_iface.c b/yjit_iface.c index 60b25cd8e9..01075ea1ee 100644 --- a/yjit_iface.c +++ b/yjit_iface.c @@ -1048,9 +1048,12 @@ rb_yjit_init(struct rb_yjit_options *options) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L1048 rb_yjit_opts = *options; rb_yjit_opts.yjit_enabled = true; - // Normalize command-line options + // Normalize command-line options to default values + if (rb_yjit_opts.exec_mem_size < 1) { + rb_yjit_opts.exec_mem_size = 256; + } if (rb_yjit_opts.call_threshold < 1) { - rb_yjit_opts.call_threshold = 2; + rb_yjit_opts.call_threshold = 10; } if (rb_yjit_opts.version_limit < 1) { rb_yjit_opts.version_limit = 4; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/