|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Rails Foundation Docs, Query Logs source_location, Dockerfile gets jemalloc" |
| 4 | +categories: news |
| 5 | +author: zzak |
| 6 | +og_image: assets/images/this-week-in-rails.png |
| 7 | +published: true |
| 8 | +date: 2024-02-09 |
| 9 | +--- |
| 10 | + |
| 11 | + |
| 12 | +Hi, it's [zzak](https://github.com/zzak). Let's explore this week's changes in the Rails codebase. |
| 13 | + |
| 14 | +[Rails Foundation Docs](https://github.com/rails/rails/pulls?q=is%3Apr+is%3Aopen+label%3A%22rails+foundation%22) |
| 15 | +A team has been [formed](https://rubyonrails.org/2024/2/6/documentation-update-work-has-begun) to improve the existing Rails documentation. PRs from this project will stay open for one week for community review. Open this week: |
| 16 | +* ActiveJob.perform_all_later |
| 17 | +* Action Text |
| 18 | +* Action Mailbox |
| 19 | + |
| 20 | +More to come! |
| 21 | + |
| 22 | +[Properly synchronize `Mysql2Adapter#active?` and `TrilogyAdapter#active?`](https://github.com/rails/rails/pull/51012) |
| 23 | +As well as `disconnect!` and `verify!`. |
| 24 | +This generally isn't a big problem as connections must not be shared between threads, but is required when running transactional tests or system tests and could lead to a SEGV. |
| 25 | + |
| 26 | +[Implement "Rails::TestUnitReporter#prerecord"](https://github.com/rails/rails/pull/50984) |
| 27 | +By adding this method to Rails TestUnitReporter class, Minitest will pick it up and invoke it before invoking the test, allowing to print the test name in advance. |
| 28 | +This is useful to debug slow and stuck tests by turning on verbose mode. This way the stuck test name is printed before the process deadlocks. |
| 29 | + |
| 30 | +[Fix JSON-encoding ActiveStorage::Filename](https://github.com/rails/rails/pull/50982) |
| 31 | +This PR fixes a bug where quotes were missing from the filename, generating invalid json. |
| 32 | + |
| 33 | +```ruby |
| 34 | +JSON.generate(foo: ActiveStorage::Filename.new("bar.pdf")) # => '{"foo":bar.pdf}' |
| 35 | +``` |
| 36 | + |
| 37 | +[Support `:source_location` tag option for query log tags](https://github.com/rails/rails/pull/50969) |
| 38 | +This PR adds support for showing where a query is defined the Rails logs when using [Active Record Query Logs](https://api.rubyonrails.org/classes/ActiveRecord/QueryLogs.html). |
| 39 | + |
| 40 | +```ruby |
| 41 | +# application.rb |
| 42 | +config.active_record.query_log_tags_enabled = true |
| 43 | +config.active_record.query_log_tags = [ :source_location ] |
| 44 | +``` |
| 45 | + |
| 46 | +[Setup jemalloc in default Dockerfile to optimize memory allocation](https://github.com/rails/rails/pull/50943) |
| 47 | +Ruby's use of `malloc` can create [memory fragmentation problems](https://www.speedshop.co/2017/12/04/malloc-doubles-ruby-memory.html), especially when using multiple threads like Puma does. |
| 48 | +Switching to an allocator that uses different patterns to avoid fragmentation can decrease memory usage by a substantial margin. |
| 49 | + |
| 50 | + |
| 51 | +_You can view the whole list of changes [here](https://github.com/rails/rails/compare/@%7B2024-02-02%7D...main@%7B2024-02-09%7D)._ |
| 52 | +_We had [18 contributors](https://contributors.rubyonrails.org/contributors/in-time-window/20240202-20240209) to the Rails codebase this past week!_ |
| 53 | + |
| 54 | +Until next time! |
| 55 | + |
| 56 | +_[Subscribe](https://world.hey.com/this.week.in.rails) to get these updates mailed to you._ |
0 commit comments