You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement binary encoding for date and time types #342
I added some SpeedTests around Date and Time, which do a tightloop roundtrip test. I run for 60 seconds before and after the change and compare.
Frankly I'm surprised efficiency isn't improved further, in the case of Postgresql time it's almost a direct translation from DateTime (or more precisely, from TimeSpan) - all you need to do is multiply/divide by ten since Postgresql's resolution is one microsecond and .NET's is 100 nanoseconds...
Frankly I'm surprised efficiency isn't improved further, in the case of Postgresql time it's almost a direct translation from DateTime (or more precisely, from TimeSpan) - all you need to do is multiply/divide by ten since Postgresql's resolution is one microsecond and .NET's is 100 nanoseconds...
Unless there is something else holding up, maybe the binary encoding hasn't a so much better performance than text after all, or maybe for this particular type there are many other things involved in storing or post processing the value which makes the performance of binary encoding less impacting.
One thorny detail: Postgresql can be compiled with 64-bit timestamps (the default) or with a floating-point representation of them; this changes the binary representation entirely. This information is sent at startup-time via the integer_datetimes parameter.
This would mean an architecture change, as the binary converters (both way) would depend on the connector. Will probably leave this for now, pick up after the performance work in #385 is done.
FYI, pushed commit to check for integer_datetimes and refuse to read/write if it isn't on. Type handlers can now optionally accept their connector to modify behavior based on parameters.
Activity
roji commentedon Oct 16, 2014
Implemented binary encoding for date only for now, performance increase of about 12%.
franciscojunior commentedon Oct 16, 2014
That's excellent, @roji !
roji commentedon Oct 18, 2014
Binary for time, performance increase of about 16%
Emill commentedon Oct 18, 2014
How do you measure performance?
roji commentedon Oct 18, 2014
I added some SpeedTests around Date and Time, which do a tightloop roundtrip test. I run for 60 seconds before and after the change and compare.
Frankly I'm surprised efficiency isn't improved further, in the case of Postgresql time it's almost a direct translation from DateTime (or more precisely, from TimeSpan) - all you need to do is multiply/divide by ten since Postgresql's resolution is one microsecond and .NET's is 100 nanoseconds...
franciscojunior commentedon Oct 18, 2014
Unless there is something else holding up, maybe the binary encoding hasn't a so much better performance than text after all, or maybe for this particular type there are many other things involved in storing or post processing the value which makes the performance of binary encoding less impacting.
roji commentedon Oct 18, 2014
Well, even if it's not 50%, 16% percent for "free" is nice too :)
franciscojunior commentedon Oct 18, 2014
Sure!
I think it is very nice! 16% is a value which can't be underestimated. :)
roji commentedon Oct 18, 2014
One thorny detail: Postgresql can be compiled with 64-bit timestamps (the default) or with a floating-point representation of them; this changes the binary representation entirely. This information is sent at startup-time via the integer_datetimes parameter.
This would mean an architecture change, as the binary converters (both way) would depend on the connector. Will probably leave this for now, pick up after the performance work in #385 is done.
roji commentedon Jan 25, 2015
FYI, pushed commit to check for integer_datetimes and refuse to read/write if it isn't on. Type handlers can now optionally accept their connector to modify behavior based on parameters.
roji commentedon Mar 23, 2015
Done, see additional discussion in #347