You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When `dirties` was [added][1] as an option to `uncached`,
`{en,dis}able_query_cache!` were changed to use multiple assignment.
However, multiple assignment allocates an array and is not really
necessary for these methods.
[1]: 5d528ba
Surprisingly, this showed up in a production profile as a large
allocator.
Reproduction:
```ruby
require "active_record"
require "memory_profiler"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
report = MemoryProfiler.report do
10000.times do
ActiveRecord::Base.connection.enable_query_cache!
end
end
report.pretty_print
```
Before:
```
bundle exec ruby eqc.rb | rg "allocated objects by class" -A 10
allocated objects by class
-----------------------------------
10093 Array
1551 String
12 Class
7 Hash
3 File
2 Proc
2 Thread::Backtrace
2 Thread::Backtrace::Location
2 Thread::Mutex
```
After:
```
bundle exec ruby eqc.rb | rg "allocated objects by class" -A 10
allocated objects by class
-----------------------------------
1551 String
93 Array
12 Class
7 Hash
3 File
2 Proc
2 Thread::Backtrace
2 Thread::Backtrace::Location
2 Thread::Mutex
```
0 commit comments