diff options
author | Maxime Chevalier-Boisvert <maximechevalierb@gmail.com> | 2021-05-26 15:25:50 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:35 -0400 |
commit | b415ceb92e464011a9326c9cb5e15a84c39da330 (patch) | |
tree | 5b42a1b39408a81d60215929b4f6e138e3ab57b8 | |
parent | 764740c6615292dc994707b964c135871149fb2b (diff) | |
download | ruby-b415ceb92e464011a9326c9cb5e15a84c39da330.tar.gz |
Increase default YJIT call threshold to 10. Add exec mem size arg. (#52)
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | ruby.c | 5 | ||||
-rw-r--r-- | yjit.h | 3 | ||||
-rw-r--r-- | yjit_codegen.c | 2 | ||||
-rw-r--r-- | yjit_iface.c | 7 |
5 files changed, 20 insertions, 10 deletions
@@ -82,11 +82,12 @@ The machine code generated for a given method can be printed by adding `puts YJI 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: - `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`) @@ -1036,7 +1036,10 @@ setup_yjit_options(const char *s, struct rb_yjit_options *yjit_opt) 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")) { @@ -33,6 +33,9 @@ struct rb_yjit_options { // 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 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) 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; |