mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 03:33:39 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
31 lines
748 B
Ruby
31 lines
748 B
Ruby
# frozen_string_literal: true
|
|
|
|
start = Time.now
|
|
require 'objspace'
|
|
require File.expand_path("../../config/environment", __FILE__)
|
|
|
|
# preload stuff
|
|
I18n.t(:posts)
|
|
|
|
# load up all models and schema
|
|
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
|
|
table.classify.constantize.first rescue nil
|
|
end
|
|
|
|
# router warm up
|
|
Rails.application.routes.recognize_path('abc') rescue nil
|
|
|
|
puts "Ruby version #{RUBY_VERSION} p#{RUBY_PATCHLEVEL}"
|
|
|
|
puts "Bootup time: #{Time.now - start} secs"
|
|
|
|
GC.start
|
|
|
|
puts "RSS: #{`ps -o rss -p #{$$}`.chomp.split("\n").last.to_i} KB"
|
|
|
|
s = ObjectSpace.each_object(String).map do |o|
|
|
ObjectSpace.memsize_of(o) + 40 # rvalue size on x64
|
|
end
|
|
|
|
puts "Total strings: #{s.count} space used: #{s.sum} bytes"
|