Non-controversial rewrite RULES for time package

Hi, The time package is too slow. :( A prime example is diffUTCTime, which invokes utcTimeToPOSIXSeconds, which in turn calls realToFrac :: DiffTime -> NominalDiffTime. The former of these two types notionally accounts for leap seconds, while the latter does not. Both are newtypes around Data.Fixed.Pico. Since realToFrac is used in the library only when we know the difference is within one day, the two notions coincide, and there is no need to account for leap seconds. Indeed it currently (or rather, its implementation of "fromRational . toRational") behaves as such. I propose we include some rewrite RULES to eliminate the round-trip via Rational. For the attached benchmark, I get a ~4x improvement in speed. Discussion period: 2 weeks. Cheers, /Liyang

On 25 September 2011 20:12, Liyang HU
Hi,
The time package is too slow. :(
A prime example is diffUTCTime, which invokes utcTimeToPOSIXSeconds, which in turn calls realToFrac :: DiffTime -> NominalDiffTime. The former of these two types notionally accounts for leap seconds, while the latter does not. Both are newtypes around Data.Fixed.Pico.
Since realToFrac is used in the library only when we know the difference is within one day, the two notions coincide, and there is no need to account for leap seconds. Indeed it currently (or rather, its implementation of "fromRational . toRational") behaves as such.
I propose we include some rewrite RULES to eliminate the round-trip via Rational. For the attached benchmark, I get a ~4x improvement in speed.
Discussion period: 2 weeks.
I thought we only made proposals here for packages which have the maintainer set to libraries@haskell.org; since time is maintained by Ashley Yakeley, wouldn't you be better off just proposing this to him directly? (I've CC'd this to him to make sure he gets it). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

Now on Hackage, version 1.4.0.1 of time includes the rewrite RULES provided by Liyang HU. -- Ashley On 25/09/11 03:12, Liyang HU wrote:
Hi,
The time package is too slow. :(
A prime example is diffUTCTime, which invokes utcTimeToPOSIXSeconds, which in turn calls realToFrac :: DiffTime -> NominalDiffTime. The former of these two types notionally accounts for leap seconds, while the latter does not. Both are newtypes around Data.Fixed.Pico.
Since realToFrac is used in the library only when we know the difference is within one day, the two notions coincide, and there is no need to account for leap seconds. Indeed it currently (or rather, its implementation of "fromRational . toRational") behaves as such.
I propose we include some rewrite RULES to eliminate the round-trip via Rational. For the attached benchmark, I get a ~4x improvement in speed.
Discussion period: 2 weeks.
Cheers, /Liyang
participants (3)
-
Ashley Yakeley
-
Ivan Lazar Miljenovic
-
Liyang HU