{"id":15101714,"url":"https://github.com/at1as/rspec_jit","last_synced_at":"2026-02-02T15:06:29.011Z","repository":{"id":56892893,"uuid":"161452753","full_name":"at1as/rspec_jit","owner":"at1as","description":"Run RSpec tests with ruby's JIT compiler enabled","archived":false,"fork":false,"pushed_at":"2018-12-12T07:59:16.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T11:57:44.027Z","etag":null,"topics":["jit","just-in-time","rspec","ruby","spec","test","test-framework","testing"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/at1as.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-12T07:58:35.000Z","updated_at":"2024-08-06T05:33:02.000Z","dependencies_parsed_at":"2022-08-21T01:50:13.876Z","dependency_job_id":null,"html_url":"https://github.com/at1as/rspec_jit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/at1as/rspec_jit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at1as%2Frspec_jit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at1as%2Frspec_jit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at1as%2Frspec_jit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at1as%2Frspec_jit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/at1as","download_url":"https://codeload.github.com/at1as/rspec_jit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/at1as%2Frspec_jit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259340616,"owners_count":22843025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jit","just-in-time","rspec","ruby","spec","test","test-framework","testing"],"created_at":"2024-09-25T18:28:49.030Z","updated_at":"2026-02-02T15:06:23.983Z","avatar_url":"https://github.com/at1as.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Runs RSpec with MJIT enabled\n\nRuby 2.6 added an experimental Just In Time compiler. It is disabled by default, but can be enabled by providing the `--jit` flag to the Ruby executable.\n\n### Installation\n\nrpsec_jit is published as a [gem](https://rubygems.org/gems/rspec_jit)\n\n```\ngem install rspec_jit\n```\n\n### Motivation\n\nA JIT makes certain things faster, however not everything will benefit, and not everything is fully supported (Rails still slows down significantly with the JIT, and ActiveRecord and Nokogiri are not fully supported).\n\nThe JIT introduces extra latency during it's \"warm up\" period. Java is famous for very long start up times. The JIT will also increase memory usage.\n\nIt can be tough to tell if the current implementation of the JIT will speed up a given program. I've had mixed results so far. That's why we benchmark (and why we need an easy way to enable or disable the JIT)!\n\n\n### Running RSpec with JIT\n\nPatching RSpec to pass the `jit` flag is unfortunately not a tenable solution. The `--jit` flag must prceede the rspec executable, and this is not possible after the ruby process has started. Patching RSpec to pass the `--jit` flag as below does not not actually enable the JIT. The order of `...rspec` and `--jit` would need to be reversed.\n\n```\n# JIT will not actually be enabled\n\nruby /usr/local/bin/rspec --jit mjit_enabled_spec.rb\n```\n\nAlthough its use is discouraged, instead of using the rspec binary `rspec ...`, RSpec can be invoked the following way, and this will allow us to enable the JIT:\n\n```\n$ ruby --jit -Ilib -Ispec -rrspec/autorun spec/test_file_spec.rb\n```\n\nThis allows us to force enable/disable the JIT by providing or omitting the flag from Ruby\n\nThis is rather clunky, and an easier way would be desirable.\n\n### Verifying the JIT is actually enabled\n\nThis program will run rspec with the JIT enabled if the ruby version is at least 2.6.X (the version in which the JIT was added). If an older version of Ruby is used, it will simply run rspec and omit the flag. \n\nSimple test case to verify if the JIT is enabled\n\n```\nrequire 'rspec'\n\nRSpec.describe RubyVM::MJIT do\n  it \"mjit should be enabled\" do\n    expect(defined?(RubyVM::MJIT) \u0026\u0026 RubyVM::MJIT.enabled?).to eq(true)\n  end\nend\n\n```\n\n### Gotchas\n\nAt this stage, This is purely an experimental endeavor. RSpec is not currently designed to make use of the JIT.\n\nIts codebase will likely require updates to call `RubyVM::MJIT.pause` and `RubyVM::MJIT.resume` at certain places to ensure each test is providing an accurate benchmark. This script may only be useful for long running tests, or may not be useful at all. It will require some deeper understand of how the JIT is implemented and profiling of its effects to have a clearer idea.\n\n\n### Environment\n\nTested with:\n* MacOS 10.12 \n* bash \u0026 zsh shells \n* Ruby versions 2.3, 2.4, 2.5, 2.6.0-rc1\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fat1as%2Frspec_jit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fat1as%2Frspec_jit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fat1as%2Frspec_jit/lists"}