{"id":15691979,"url":"https://github.com/byroot/monorails","last_synced_at":"2026-04-01T18:42:20.891Z","repository":{"id":25448642,"uuid":"28878617","full_name":"byroot/monorails","owner":"byroot","description":"A set of Rails patches to speedup applications that do not need thread safety.","archived":false,"fork":false,"pushed_at":"2015-11-18T03:10:48.000Z","size":180,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-27T22:57:10.070Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byroot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-06T19:04:44.000Z","updated_at":"2018-04-06T12:23:45.000Z","dependencies_parsed_at":"2022-07-24T06:16:06.489Z","dependency_job_id":null,"html_url":"https://github.com/byroot/monorails","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/byroot/monorails","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmonorails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmonorails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmonorails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmonorails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byroot","download_url":"https://codeload.github.com/byroot/monorails/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmonorails/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-03T18:27:06.105Z","updated_at":"2026-04-01T18:42:20.867Z","avatar_url":"https://github.com/byroot.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monorails\n\n[![Build Status](https://travis-ci.org/byroot/monorails.svg)](http://travis-ci.org/byroot/monorails)\n[![Gem Version](https://badge.fury.io/rb/monorails.png)](http://badge.fury.io/rb/byroot/monorails)\n\nMonkey patch Rails to make it faster in non thread safe applications\n\n**CAUTION: Use this gem at your own risk.**\n\nIf your application is not doing any threading, then `monorails` can bring you a few performance\nimprovements at the cost of losing thread safety.\n\n## Explanation\n\nFirst `monorails` includes `thread_hazardous` that bring a substential performance improvement.\n[See it's readme for explanation](https://github.com/byroot/thread_hazardous#explanation).\n\n`monorails` also patches `ActiveSupport::PerThreadRegistry` that is used in a couple Rails hotspots.\n`PerThreadRegistry` stores an instance in `Thread.current` which is way slower than a regular instance variable:\n\n```\nCalculating -------------------------------------\n         thread-safe    25.176k i/100ms\n       thread-unsafe    30.069k i/100ms\n-------------------------------------------------\n         thread-safe      1.480M (± 6.5%) i/s -      7.377M\n       thread-unsafe      2.480M (± 7.2%) i/s -     12.328M\n```\nFor full details see [the benchmark implementation](https://gist.github.com/byroot/919e7756be7f89ec19af)\n\n`monorails` also backport [a performance patch from Rails 4.2](https://github.com/rails/rails/commit/28d52c59f2cb32180ca24770bf95597ea3ad8198) for older versions.\n\nThese operations themselves are not that costly, but they are often used in heavy hotspots, especially in Rails, so in the end it adds up.\nHere's a profiling real life application under real life load:\n\n```\n==================================\n  Mode: wall(1000)\n  Samples: 15836 (0.35% miss rate)\n  GC: 696 (4.40%)\n==================================\nTOTAL (pct)   SAMPLES (pct)   FRAME\n429   (2.5%)    429   (2.5%)  ActiveSupport::PerThreadRegistry#per_thread_registry_instance\n419   (2.6%)    419   (2.6%)  ThreadSafe::NonConcurrentCacheBackend#[]\n208   (1.3%)    208   (1.3%)  ThreadSafe::NonConcurrentCacheBackend#dupped_backend\n 75   (0.5%)     75   (0.5%)  block in ThreadSafe::Cache#values\n151   (0.9%)    147   (0.9%)  block in ActiveRecord::AttributeMethods::ClassMethods#define_attribute_methods\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'monorails'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install monorails\n\n## Usage\n\nNothing more to do, it's all automatic.\n\n## Contributing\n\n1. Fork it ( https://github.com/byroot/monorails/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyroot%2Fmonorails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyroot%2Fmonorails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyroot%2Fmonorails/lists"}