-
Notifications
You must be signed in to change notification settings - Fork 11
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
Rewriting decoder buffering #7
Conversation
Decoder had several bugs in its buffering logic that caused it to report invalid data on redis data that was actually valid. In particular the "second attempt to read" check incorrectly returns error when the data is larger than the buffer size and the buffer is initially empty. This also fixes the (separate, but related) error reported in gosexy/redis: gosexy/redis#42 This change rewrites the buffering logic to use standard bufio APIs instead of reimplementing buffering logic in this library.
Thanks a lot @mtlynch! Please allow me some time to go through it. |
I still need to go through the code but I am bit a concerned on the speed penalties of using the This is what I got after running the benchmarking program on your proposal:
Against the current implementation (which is compared to the JSON library):
But that's does not prove anything, my current implementation is probably flawed and that might be affecting benchmarking... so in order to actually compare both solutions in terms of speed I guess I'd have to fix this bug in my code and try again. |
Yes, I am seeing similar results. I think the implementation in master is "cheating" a bit because I noticed that it throws out some data, but I don't think that explains the drastic performance difference. I profiled it a bit (results below), but I wasn't able to determine the cause. I suspect that the proposed code is doing some sort of unnecessary copying of an array when it could just pass a reference but I can't pinpoint anywhere this is happening. Between the two, I'd prefer the proposed version because I'd rather have slower code that yields correct results than have faster code that yields "usually" correct results. : ) master: https://gist.github.com/mtlynch/dfaac62b22d66a5015a9
|
Hello @mtlynch, I just added a test case for this error and tested with and without your solution.
I have to agree with that. Besides the bug you referred has been open for some days and I haven't been able to take a stab at it, so I guess it's better fixed than perfect. I'm still concerned about speed and I'll eventually try (more carefully) with Thanks, |
Decoder had several bugs in its buffering logic that caused it to report
invalid data on redis data that was actually valid.
In particular the "second attempt to read" check incorrectly returns
error when the data is larger than the buffer size and the buffer is
initially empty.
This also fixes the (separate, but related) error reported in
gosexy/redis:
gosexy/redis#42
This change rewrites the buffering logic to use standard bufio APIs
instead of reimplementing buffering logic in this library.