mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
PERF: only require the rss library if used
Before: Total allocated: 257909321 bytes (2514134 objects) Total retained: 39681579 bytes (343387 objects) allocated memory by gem ----------------------------------- 42875979 rss retained memory by gem ----------------------------------- 2080188 rss retained objects by gem ----------------------------------- 13052 rss After: Total allocated: 210562047 bytes (2252030 objects) Total retained: 37433816 bytes (328635 objects) ---- So, 2 less megabytes on boot and 13000 objects stuck in ruby heaps forever.
This commit is contained in:
21
script/boot_mem.rb
Normal file
21
script/boot_mem.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# simple script to measure memory at boot
|
||||
|
||||
if ENV['RAILS_ENV'] != "production"
|
||||
exec "RAILS_ENV=production ruby #{__FILE__}"
|
||||
end
|
||||
|
||||
require 'memory_profiler'
|
||||
|
||||
MemoryProfiler.report do
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
|
||||
Rails.application.routes.recognize_path('abc') rescue nil
|
||||
|
||||
# load up the yaml for the localization bits, in master process
|
||||
I18n.t(:posts)
|
||||
|
||||
# load up all models and schema
|
||||
(ActiveRecord::Base.connection.tables - %w[schema_migrations versions]).each do |table|
|
||||
table.classify.constantize.first rescue nil
|
||||
end
|
||||
end.pretty_print
|
Reference in New Issue
Block a user