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

Nom parser #129

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@gsquire

gsquire commented Jul 8, 2017

This is an extremely rough start to using nom. I am sharing it to get thoughts on the layout as well as how to debug the unit tests. Perhaps I have written the parsers in a completely wrong way.

If this seems like it will not fit into this library, then feel free to close it. Thanks for looking.

Related to #81

Show outdated Hide outdated src/parser.rs
'*' => self.parse_bulk(),
'-' => self.parse_error(),
_ => fail!((ErrorKind::ResponseError, "Invalid response when parsing value")),
let mut buf = [0; 4];

This comment has been minimized.

@gsquire

gsquire Jul 8, 2017

I need to figure out the best way to read from the socket. This is just for testing locally now.

@gsquire

gsquire Jul 8, 2017

I need to figure out the best way to read from the socket. This is just for testing locally now.

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Jul 13, 2017

@badboy Sorry to ping you directly, but I am curious if you find this PR valuable? If so I will keep iterating on it.

gsquire commented Jul 13, 2017

@badboy Sorry to ping you directly, but I am curious if you find this PR valuable? If so I will keep iterating on it.

@badboy

This comment has been minimized.

Show comment
Hide comment
@badboy

badboy Jul 13, 2017

Collaborator

First, I appreciate your work here, regardless if we will merge it in the end.
I hadn't had time to take a look, but I will free up some time tomorrow and give you feedback then. Is that ok?

Collaborator

badboy commented Jul 13, 2017

First, I appreciate your work here, regardless if we will merge it in the end.
I hadn't had time to take a look, but I will free up some time tomorrow and give you feedback then. Is that ok?

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Jul 13, 2017

In any case I will keep working on it. I wanted to see if it would be a hard no or not :)

No rush on the feedback by the way! Whenever is convenient.

gsquire commented Jul 13, 2017

In any case I will keep working on it. I wanted to see if it would be a hard no or not :)

No rush on the feedback by the way! Whenever is convenient.

@jwilm

This comment has been minimized.

Show comment
Hide comment
@jwilm

jwilm Jul 13, 2017

Collaborator

@gsquire I am personally curious about performance difference between the current parser and your nom based one. Any chance you can provide some numbers?

Collaborator

jwilm commented Jul 13, 2017

@gsquire I am personally curious about performance difference between the current parser and your nom based one. Any chance you can provide some numbers?

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Jul 13, 2017

@jwilm I don't have any numbers I am confident in now and am more focused on correctness. If it proves to be the same or worse then I will abandon this.

gsquire commented Jul 13, 2017

@jwilm I don't have any numbers I am confident in now and am more focused on correctness. If it proves to be the same or worse then I will abandon this.

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Jul 14, 2017

I have to say...I am puzzled why reading from the socket causes the test to hang. The next step to try is a tcpdump of the traffic.

gsquire commented Jul 14, 2017

I have to say...I am puzzled why reading from the socket causes the test to hang. The next step to try is a tcpdump of the traffic.

Show outdated Hide outdated src/parser.rs
'-' => self.parse_error(),
_ => fail!((ErrorKind::ResponseError, "Invalid response when parsing value")),
let mut buf = vec![];
match self.buf_reader.read_to_end(&mut buf) {

This comment has been minimized.

@badboy

badboy Jul 15, 2017

Collaborator

reading a stream to end will wait for an EOF, meaning for the connection to close.
That's definitely not what you want here.
You would want to read as much as possible, then try to parse it and if necessary read more of it.

@badboy

badboy Jul 15, 2017

Collaborator

reading a stream to end will wait for an EOF, meaning for the connection to close.
That's definitely not what you want here.
You would want to read as much as possible, then try to parse it and if necessary read more of it.

This comment has been minimized.

@gsquire

gsquire Jul 17, 2017

I am working on this now, and am trying to figure out the most efficient way to do so.

@gsquire

gsquire Jul 17, 2017

I am working on this now, and am trying to figure out the most efficient way to do so.

Some(detail) => fail!((kind, desc, detail.to_string())),
None => fail!((kind, desc)),
fn parse_error(line: &str) -> RedisResult<Value> {
let desc = "An error was signaled by the server";

This comment has been minimized.

@badboy

badboy Jul 15, 2017

Collaborator

signalled

@badboy

badboy Jul 15, 2017

Collaborator

signalled

This comment has been minimized.

@badboy

badboy Jul 15, 2017

Collaborator

Hm, okay, both spellings are ok. Don't mind then.

@badboy

badboy Jul 15, 2017

Collaborator

Hm, okay, both spellings are ok. Don't mind then.

@badboy

This comment has been minimized.

Show comment
Hide comment
@badboy

badboy Jul 15, 2017

Collaborator

It's definitely off to a good start.

@jwilm I don't have any numbers I am confident in now and am more focused on correctness. If it proves to be the same or worse then I will abandon this.

The current parser is pretty simple and not optimized at all. I'm sure there is some low-hanging fruit to speed it up.
However, we currently don't have any good benchmark for the parser. The 3 bundled benchmarks are are a starting point, but don't exercise most parts of the parser.

Collaborator

badboy commented Jul 15, 2017

It's definitely off to a good start.

@jwilm I don't have any numbers I am confident in now and am more focused on correctness. If it proves to be the same or worse then I will abandon this.

The current parser is pretty simple and not optimized at all. I'm sure there is some low-hanging fruit to speed it up.
However, we currently don't have any good benchmark for the parser. The 3 bundled benchmarks are are a starting point, but don't exercise most parts of the parser.

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Jul 18, 2017

I need to read up on nom and why I am getting Alt errors when feeding input. The unit tests I had written and tested separately all seemed happy before migrating it to this crate. I will keep digging into it.

gsquire commented Jul 18, 2017

I need to read up on nom and why I am getting Alt errors when feeding input. The unit tests I had written and tested separately all seemed happy before migrating it to this crate. I will keep digging into it.

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Jul 22, 2017

Another status update...

It's just hanging on the transaction tests now. I know the tests are failing but I will attend to that once I am done figuring out why it's not reading all that it should.

gsquire commented Jul 22, 2017

Another status update...

It's just hanging on the transaction tests now. I know the tests are failing but I will attend to that once I am done figuring out why it's not reading all that it should.

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Aug 14, 2017

@badboy I haven't had much time to look at this as I just moved into a new place. I still plan on getting this working and will return to it in due time. If you have any free time, you can edit my PR too. :)

gsquire commented Aug 14, 2017

@badboy I haven't had much time to look at this as I just moved into a new place. I still plan on getting this working and will return to it in due time. If you have any free time, you can edit my PR too. :)

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Aug 22, 2017

The transaction tests are failing on this line: https://github.com/mitsuhiko/redis-rs/pull/129/files#diff-2c09afcdc3c420ab0678ba9b5e83959cR35

The read is blocking for some reason and I cannot figure out why. After this I will see what the parser errors are.

gsquire commented Aug 22, 2017

The transaction tests are failing on this line: https://github.com/mitsuhiko/redis-rs/pull/129/files#diff-2c09afcdc3c420ab0678ba9b5e83959cR35

The read is blocking for some reason and I cannot figure out why. After this I will see what the parser errors are.

@gsquire

This comment has been minimized.

Show comment
Hide comment
@gsquire

gsquire Aug 26, 2017

I have squashed and rebased my changes.

For now I moved back to the old way of reading byte by byte since the buffered reader would just block for transactions. I would love to hear ideas as to why this could have been or what could be done to fix it. Also, there is a lot of refactoring I will get to as I haven't focused on code quality much to my chagrin.

Let me know your thoughts and thanks for your patience with this PR.

gsquire commented Aug 26, 2017

I have squashed and rebased my changes.

For now I moved back to the old way of reading byte by byte since the buffered reader would just block for transactions. I would love to hear ideas as to why this could have been or what could be done to fix it. Also, there is a lot of refactoring I will get to as I haven't focused on code quality much to my chagrin.

Let me know your thoughts and thanks for your patience with this PR.

@gsquire gsquire closed this Feb 3, 2018

@gsquire gsquire deleted the gsquire:nom-parser branch Feb 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment