关闭ActiveSupport ::订阅者/通知

时间:2016-07-14 20:16:56

标签: performance activerecord sinatra activesupport

我使用stackprof来分析使用Active Record的sinatra应用程序。当我检查生成的文件的输出时,我得到以下内容:

[vagrant@localhost vagrant]$ bin/stackprof tmp/stackprof-cpu-5754-1468440335.dump --text --limit 10
==================================
  Mode: cpu(1000)
  Samples: 146 (1.35% miss rate)
  GC: 7 (4.79%)
==================================
 TOTAL    (pct)     SAMPLES    (pct)     FRAME
    19  (13.0%)          18  (12.3%)     ActiveSupport::Subscriber#start
    10   (6.8%)          10   (6.8%)     ActiveRecord::Timestamp#current_time_from_proper_timezone
    13   (8.9%)           9   (6.2%)     Logger#add
   285 (195.2%)           5   (3.4%)     Statsd#time
     5   (3.4%)           5   (3.4%)     block in ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter#execute
     6   (4.1%)           5   (3.4%)     ActiveRecord::LazyAttributeHash#[]
    12   (8.2%)           5   (3.4%)     ActiveSupport::Subscriber#finish
     4   (2.7%)           4   (2.7%)     ActiveRecord::Relation#initialize_copy
     6   (4.1%)           4   (2.7%)     block (2 levels) in Class#class_attribute
     3   (2.1%)           3   (2.1%)     Logger::Formatter#format_datetime

当我订阅并记录通知时,它们只是AR查询通知,我现在并不关心。

似乎ActiveSupport :: Subscribers / notifications也是性能瓶颈。有没有办法通过ActiveSupport配置禁用这些?

0 个答案:

没有答案