Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNanosecond precision loss in 'parseDouble' #12
Comments
|
Thanks for the report -- appreciate the detailed look at it. Could you test your suggestion on a few input values and try a before/after? |
|
Sure, I'll do something more systematic over the weekend and let you know.
…On 01/27/2017 06:10 PM, Dirk Eddelbuettel wrote:
Thanks for the report -- appreciate the detailed look at it.
Could you test your suggestion on a few input values and try a
before/after?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYOArDc-ITZ8VgVKbNbo_TLAJp3byV2bks5rWnlVgaJpZM4LwTPw>.
|
|
I'm still at work and right now a little stunned by your ztsdb.org site. We'll probably email or message some more in the future. What's your use case? |
|
Good suggestion for a fix: R> library(RcppCCTZ)
R> packageVersion("RcppCCTZ")
[1] ‘0.2.0.1’
R> parseDouble("2120-01-01T00:00:59.987654321+00:00")
[,1] [,2]
[1,] 4733510459 987654321
R> Commited in fe8d609. |
|
My background is in finance and before that telecoms.
I wanted a time-series DBMS that is competent for financial data
collection and storage, but at the same time can process queries that
can sieve through large amounts of data to return a smaller and relevant
set to R for data analysis. Still with finance in mind, I needed
functionality that can compare and align observations from markets
around the world: that's the use case for the extended civil time
handling capabilities.
I'm hoping though it is general enough to be useful for scientific research.
I've just released it and there are some things I'm unhappy with, but of
course the earlier I can get feedback, the better I can orient my effort.
…On 01/27/2017 06:26 PM, Dirk Eddelbuettel wrote:
I'm still at work and right now a little stunned by your ztsdb.org
site. We'll probably email or message some more in the future.
What's your use case?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYOArNPV0hVgh8bv0UmJf_t4gdBT9M2rks5rWn0ogaJpZM4LwTPw>.
|
|
I work in finance and am aware of what's out there. This is rather interesting to me (of course because of the tooling). Build just failed on 16.10 / amd64. It does not tolerate crpcut missing. Once installed, the parser does not build:
Can you enable issue tickers over at Gitlab? |
|
OK, thanks, will fix the crpcut missing case.
Will test the compilation on 16.10.
Is it a bison error or a compiler error?
…On 01/27/2017 07:12 PM, Dirk Eddelbuettel wrote:
I work in finance and am aware of what's out there. This is rather
interesting to me (of course because of the tooling).
Build just failed on 16.10 / amd64. It does not tolerate crpcut
missing. Once installed, the parser does not build.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYOArABvYNWkXgLZCYvMTFZTeI2tl-aDks5rWogKgaJpZM4LwTPw>.
|
|
I am not sure. Looks like a compiler error to me : "failing to create parser.cpp.o". But bison may be involved. Very vanilla machine. If you could fire up Docker to replicate/chase I would appreciate it. If need be I could downgrade to another bison or flex version. I'll also try on my main box which is still 16.04. And issue tickets at Gitlab, pretty please? |
|
It works with bison as from 3.02 (there was a bison bug prior to that)
and until 3.04 which is the latest version and which I have tested, so I
don't think that's the issue, 16.10 comes with a recent enough version
of bison...
I'll figure out why the issues are not public on gitlab and will try
tonight a 16.10 image, but need to put the kids to bed first :)
Thanks a bunch for the feedback.
…On 01/27/2017 07:56 PM, Dirk Eddelbuettel wrote:
I am not sure. Looks like a compiler error to me : "failing to create
parser.cpp.o". But bison may be involved.
Very vanilla machine. If you could fire up Docker to replicate/chase I
would appreciate it. If need be I could downgrade to another bison or
flex version. I'll also try on my main box which is still 16.04.
And issue tickets at Gitlab, pretty please?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYOArL6XhdugHPRRiRm8xQGShXaBHRdvks5rWpI-gaJpZM4LwTPw>.
|
|
I looked more closely, it is a 'pickier newer compiler' issue. Once I added Now choking on
Can you please open the ability to file bugs for YOUR project at YOUR repository rather than here? I may switch to trying this on 16.04, looks like you are not ready yet for g++-6.2.0. |
|
Indeed. Fixed to compile with g++ 6.2.
Issues open to anyone with a gitlab access.
…On 01/28/2017 09:41 AM, Dirk Eddelbuettel wrote:
I looked more closely, it is a 'pickier newer compiler' issue. Once I
added |#include <numeric>| to array.hpp, it passed that file.
Now choking on
|Scanning dependencies of target ztsdb_lib [ 20%] Building CXX object
src/CMakeFiles/ztsdb_lib.dir/timezone/localtime.cpp.o [ 20%] Building
CXX object src/CMakeFiles/ztsdb_lib.dir/timezone/zone.cpp.o
/home/edd/git/ztsdb/src/timezone/zone.cpp: In member function
‘std::chrono::time_point<std::chrono::_V2::system_clock,
std::chrono::duration<long int, std::ratio<1l, 1000000000l> >
>::duration tz::Zone::getoffset(Global::dtime, int&, int) const’:
/home/edd/git/ztsdb/src/timezone/zone.cpp:138:17: error: ‘copysign’ is
not a member of ‘std’ auto sign = std::copysign(1, dir); ^~~
/home/edd/git/ztsdb/src/timezone/zone.cpp:159:1: warning: control
reaches end of non-void function [-Wreturn-type] } ^
src/CMakeFiles/ztsdb_lib.dir/build.make:93: recipe for target
'src/CMakeFiles/ztsdb_lib.dir/timezone/zone.cpp.o' failed make[3]: ***
[src/CMakeFiles/ztsdb_lib.dir/timezone/zone.cpp.o] Error 1
CMakeFiles/Makefile2:132: recipe for target
'src/CMakeFiles/ztsdb_lib.dir/all' failed make[2]: ***
[src/CMakeFiles/ztsdb_lib.dir/all] Error 2 CMakeFiles/Makefile2:106:
recipe for target 'src/CMakeFiles/ztsdb.dir/rule' failed make[1]: ***
[src/CMakeFiles/ztsdb.dir/rule] Error 2 Makefile:173: recipe for
target 'ztsdb' failed make: *** [ztsdb] Error 2
***@***.***:~/git/ztsdb/build(master)$ |
Can you please open the ability to file bugs for YOUR project at YOUR
repository rather than here?
I may switch to trying this on 16.04, looks like you are not ready yet
for g++-6.2.0.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYOArHvXXfrmOCVmR_9z_xBb1R9Tq07yks5rW1OxgaJpZM4LwTPw>.
|
|
Double awesome. Building now, and will continue conversation over there... |
|
Ran the following test; it's not exhaustive, but it tests throughout library(RcppCCTZ)
res <- matrix(0, 0, 2, dimnames=list(NULL, c("nsec", "parse")))
nsec <- 1
for (y in 1678:2261)
for (m in 1:12)
for (d in 1:28) {
s <- paste0(y,"-",sprintf("%02d", m), "-", sprintf("%02d", d),
"T00:00:01.", sprintf("%09d", nsec),"+00:00")
if (s < "1970-01-01T00:00:00.000000000+00:00")
res <- rbind(res, c(nsec, 1e9+parseDouble(s)[2]))
else
res <- rbind(res, c(nsec, parseDouble(s)[2]))
nsec <- nsec + 1
}
print(dim(res))
print(sum(res[,"parse"]-res[,"nsec"] != 0))With the old code there were 50031 errors:
With the new code in branch 'bugfix/conversion' there were no errors:
Also ran the test on a 32-bit VM and it was correct too. |
|
You are quite awesome, thank you. I was thinking I should add such a test to the regression. How long did this run? (The test is a little strange as you do 196k rbinds leading to memory ops.) But it's a start, and the result is encouraging. |
|
Even without the rbind it's too slow to be in a unit test. This issue was only with the multiplication: 'secs * 1e9', for absolute values of secs sufficiently large that produce more significant digits than a double can hold. So to test that case I would say that it's probably just as good of a test to take one negative and one positive that produce the loss of precision: for example "1680-07-17T00:00:01.000000000+00:00" and the previously mentioned "2120-01-01T00:00:59.987654321+00:00". |
|
Yes, and yes, we're on the same page. Was thinking I could just call The string creation and parsing will be moderately expensive but we could still try a few hundred or thousand points. When I get some time ... |
|
Yes, that would definitely be a better test. |
parseDouble in some cases loses the last digits of the nanoseconds.
Example:
instead of the expected result:
The problem comes from the coercion to double in parseDouble (utilities.cpp, lines 275-276):
Maybe the following works?
bug.report information: