Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8159 (closed defect: fixed)

Opened 2 years ago

Last modified 4 months ago

Minor changes to reduce number of exceptions thrown.

Reported by: blaine Assigned to: core
Priority: high Milestone: 1.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: performance optimization
Cc:

Description

We (Twitter) looked at our running Rails instances (under mongrel) and found that much of our latency was caused by extremely large amounts of time spent generating backtraces because of exceptions being raised.

The vast majority of the raised exceptions originated from the locations fixed in these two patches.

Normally, using raise / rescue wouldn't be a problem, but in many of these instances, the stack trace is hundreds of frames deep, and takes a really long time to generate. Since the generation of the stack trace happens automatically when an exception is raised, the best approach is to avoid raising exceptions altogether where avoidable.

I ran a number of benchmarks against the changes, but as mentioned above, these issues really only surface when the stack traces are large and time-consuming to generate; within the context of tests, it's not a significant difference (although relevant tests ran reliably approximately 2 milliseconds faster).

I've attached some brief output that includes the total time spent in CPU and the corresponding total time spent in CPU in backtrace generation, over one second intervals, running against our live mongrel processes.

Please contact me at blaine@obvious.com if any more information is required. Thanks!

Attachments

dont_spuriously_throw_exceptions_in_chars.diff (1.6 kB) - added by blaine on 04/24/07 06:15:31.
Reduce frequency of exceptions thrown in multibyte char handling
twitter_total_and_backtrace_cpu_time_spent.log (10.7 kB) - added by blaine on 04/24/07 06:16:51.
dont_spuriously_throw_exceptions_in_attribute_value_clone.diff (0.6 kB) - added by blaine on 04/24/07 16:40:12.

Change History

04/24/07 06:15:31 changed by blaine

  • attachment dont_spuriously_throw_exceptions_in_chars.diff added.

Reduce frequency of exceptions thrown in multibyte char handling

04/24/07 06:16:51 changed by blaine

  • attachment twitter_total_and_backtrace_cpu_time_spent.log added.

04/24/07 16:40:12 changed by blaine

  • attachment dont_spuriously_throw_exceptions_in_attribute_value_clone.diff added.

04/24/07 16:58:50 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

Closed by [6571]

05/30/08 17:57:22 changed by airforce1

12/28/08 14:06:31 changed by select

Place of origin:Guangdong ChinaModel No:YL-S01Payment Terms:L/C,T/T,Western UnionMinimum Order Quantity:500 Piece/PiecesSupply Ability:100000 Piece/Pieces per DayPackage:Blister pack

http://www.solar-water-heaters.com.cn/

03/17/09 18:36:15 changed by sneakeralley

Thanks Air Force One