Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 14348
Status: rejected
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: datetime [...] nogin.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.28
Fixed in: (no value)



Subject: For "huge" dates, from_epoch with time_zone = "local" takes forever and eats a lot of memory.
A code that does from_epoch(epoch => $date, time_zone => "local") when $date is _way_ in the future, takes enormous time and memory. Here is a code snippet that demonstrates the problem: #!/usr/bin/perl use DateTime; system("ps u $$"); $start = time(); $dt = DateTime->from_epoch(epoch => 569151104400, time_zone => "local"); $end = time(); system("ps u $$"); print "It took ", $end - $start, "seconds \n"; On my machine (DateTime 0.28, perl v5.8.3 built for x86_64-linux-thread-multi, Fedora Core 2 on 2.2Ghz Athlon _64_) the above reports spending ~2min in the from_epoch call and the process size grows by about 185MB. P.S. I came across this when the WebWork system ( http://webwork.rochester.edu/ ) became very unresponsive as a result of one professor accidentally entering year 20005 in a due date field. While WebWork should have probably rejected such "due date" (and I will file a WebWork bug report about it), DateTime shouldn't be that resource-hungry on dates in the future.
Date: Sun, 28 Aug 2005 22:25:32 -0500 (CDT)
From: Dave Rolsky <autarch [...] urth.org>
To: Guest via RT <bug-DateTime [...] rt.cpan.org>
Subject: Re: [cpan #14348] For "huge" dates, from_epoch with time_zone = "local" takes forever and eats a lot of memory.
RT-Send-Cc:
On Sun, 28 Aug 2005, Guest via RT wrote: Show quoted text
> A code that does > from_epoch(epoch => $date, time_zone => "local") > when $date is _way_ in the future, takes enormous time and memory. > > Here is a code snippet that demonstrates the problem: > > #!/usr/bin/perl > use DateTime; > system("ps u $$"); > $start = time(); > $dt = DateTime->from_epoch(epoch => 569151104400, time_zone => "local"); > $end = time(); > system("ps u $$"); > print "It took ", $end - $start, "seconds \n"; > > On my machine (DateTime 0.28, perl v5.8.3 built for > x86_64-linux-thread-multi, Fedora Core 2 on 2.2Ghz Athlon _64_) the > above reports spending ~2min in the from_epoch call and the process size > grows by about 185MB. > > P.S. I came across this when the WebWork system ( > http://webwork.rochester.edu/ ) became very unresponsive as a result of > one professor accidentally entering year 20005 in a due date field. > While WebWork should have probably rejected such "due date" (and I will > file a WebWork bug report about it), DateTime shouldn't be that > resource-hungry on dates in the future.
Well, I don't think I'd consider this a bug, but it's worth documenting somewhere. Basically, to figure out the DST transition for future dates, DT::TimeZone calculates from where it currently knows (it ships with the next 10 years, IIRC) to the date you specify. It stores the intermediate calculations so next time you ask it doesn't have to do this. This is a good thing if you're looking 20 or 30 years ahead or so, but obviously a problem for 18000 years. Anyway, I don't want to try to optimize for such an uncommon case, since anyone who actually needs to work with such dates obviously doesn't care about time zones, and can just use a floating or UTC time zone-d datetime. -dave /*=================================================== VegGuide.Org www.BookIRead.com Your guide to all that's veg. My book blog ===================================================*/
Date: Sun, 28 Aug 2005 22:26:41 -0500 (CDT)
From: Dave Rolsky <autarch [...] urth.org>
To: Guest via RT <bug-DateTime [...] rt.cpan.org>
Subject: Re: [cpan #14348] For "huge" dates, from_epoch with time_zone = "local" takes forever and eats a lot of memory.
RT-Send-Cc:
On Sun, 28 Aug 2005, Guest via RT wrote: Show quoted text
> P.S. I came across this when the WebWork system ( > http://webwork.rochester.edu/ ) became very unresponsive as a result of > one professor accidentally entering year 20005 in a due date field. > While WebWork should have probably rejected such "due date" (and I will > file a WebWork bug report about it), DateTime shouldn't be that > resource-hungry on dates in the future.
BTW, I'd suggest using some sort of JS-based calendar popup interface for date entry. Makes things much simpler, as you don't have to deal with trying to parse user input, and errors like this (as well as dates in the past, etc) are less likely. -dave /*=================================================== VegGuide.Org www.BookIRead.com Your guide to all that's veg. My book blog ===================================================*/