Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua LDB debugging: Float precision is lost in stack values and [p]rint of Lua vars #4688

Open
tw-bert opened this issue Feb 14, 2018 · 4 comments

Comments

@tw-bert
Copy link

tw-bert commented Feb 14, 2018

Redis 4.0.8

Follow up on: pkulchenko/ZeroBranePackage#66
Redis docs: https://redis.io/topics/ldb

In short: 20180212.1045 is serialized as 2.01802e+07 which is unusable (because: it's a timestamp: YYYYMMDD.HHMM). The non mantissa precision of 53 bit (15 digits in base-10) should not be lost in the serialization. In this example the precision goes down from 12 digits to 6 digits.

Possible solution: Use format "%015.15g" and/or let the user set a custom session-persistent float serialization string.

@tw-bert tw-bert changed the title Lua debugging: Float precision is lost in stack values and [p]rint of Lua vars Lua LDB debugging: Float precision is lost in stack values and [p]rint of Lua vars Feb 14, 2018
@tw-bert
Copy link
Author

tw-bert commented Jul 6, 2018

@itamarhaber : Some more people on our team are starting to use redis' ldb (with or without ZeroBraneStudio). We'd greatly appreciate some feedback on this issue.

@itamarhaber
Copy link
Member

I think this is a good suggestion, and it shouldn't break anything major as this is ldb after all. Pong @antirez ?

@antirez
Copy link
Contributor

antirez commented Jul 13, 2018

Hello @tw-bert, @itamarhaber, what conversion function is that in LDB? I've no idea about what ZeroBrane does so with the informations in this issue I'm not sure what the problem is, a set of commands directly send to the Redis LDB showing the issue would be appreciated. Thanks.

@tw-bert
Copy link
Author

tw-bert commented Jul 13, 2018

@antirez @itamarhaber Here's a repro:

tw_bert@srv-flux-dev-01:~$ printf 'local f=20180713.143205\nreturn tostring(f)' > test.lua
tw_bert@srv-flux-dev-01:~$ redis-cli -p 14213 --ldb --eval test.lua
Lua debugging session started, please use:
quit    -- End the session.
restart -- Restart the script in debug mode again.
help    -- Show Lua script debugging commands.

* Stopped at 1, stop reason = step over
-> 1   local f=20180713.143205
lua debugger> s
* Stopped at 2, stop reason = step over
-> 2   return tostring(f)
lua debugger> p
<value> f = 2.01807e+07
lua debugger> s

"20180713.143205"

(Lua debugging session ended -- dataset changes rolled back)

The issue is, that 2.01807e+07 should be serialized/cast to string as 20180713.143205 . Applying the Lua format "%015.15g" was just a suggestion, you can disregard that if you wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants