This project is archived and is in readonly mode.

#6779 new
Bogdan Gusiev

ActiveSupport::TimeWithZone in Range performance bug

Reported by Bogdan Gusiev | May 13th, 2011 @ 08:28 AM

We discovered that some operations on the Range class of ActiveSupport::TimeWithZone is slow.

Example:

(10.days.ago..3.days.ago).min

Will have more than 5 seconds execution time with both Rails 2.3.11 and 3.0.7 on Ruby 1.8.7.
The problem don't appear on Ruby 1.9.2.

Also the following code doesn't have performance issue:

(10.days.ago.to_datetime..3.days.ago.to_datetime).min

Thanks,
Bogdan

Comments and changes to this ticket

  • nmunson

    nmunson May 14th, 2011 @ 06:03 AM

    I can confirm it happens on Ruby 1.8.7 and Rails 3.0.0, the example line takes 10+ seconds to run. The "doesn't have an issue" code works instantly as it did for you as well.

  • debosh

    debosh May 15th, 2011 @ 10:32 AM

    I can also confirm.

    I've found the bug and I'm creating patch.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages