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

=str Skip parsing when buffer size < 1 #363

Merged
merged 1 commit into from
Aug 11, 2023
Merged

Conversation

He-Pin
Copy link
Member

@He-Pin He-Pin commented May 29, 2023

I think we can do a quic returning if the buffer size is zero.

Copy link
Contributor

@mdedetrich mdedetrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be considered excessive but considering we have had a regression in this area of Pekko, would it be possible to add a unit test which checks that when the buffer size is 0 to check that both current Pekko and the change in this PR both return false?

The easiest way to do this is to make seekObject() package private (so you can access it in a test) and construct JsonObjectParser (which initialises buffer to empty so buffer.length is zero) and immediately call seekObject() to see if it returns false.

If this is too difficult then let me know and I can reconsider.

@He-Pin
Copy link
Member Author

He-Pin commented May 29, 2023

It can be false if the downstream poll, but the upstream is not ready, or downstream is faster and upstream is idle.

I can add more detailed test for JsonFramming but I don't see much value to add a test for the short-circuit logic,as it's identical to the objectCompleted when the buffer is empty

As the chances this short-circuit can benefit, i think that maybe why it's not there in the firsr place.

@mdedetrich
Copy link
Contributor

tbh I am not entirely familiar with this section of Pekko, I am just being cautious/skeptical because we had a general regression here which I am trying to avoid in the future.

If you are happy with adding a more detailed JsonFraming test that would be great, I suspect you would do this in a separate PR? If so let me know and can review this in more detail in the next couple of days.

@pjfanning
Copy link
Contributor

Could we do this in v1.0.1? It's not a bug and it just doesn't feel urgent.

@mdedetrich
Copy link
Contributor

Agreed

@He-Pin
Copy link
Member Author

He-Pin commented May 29, 2023

let's defer this.

i want to add some random tests against JsonFraming.

@He-Pin He-Pin marked this pull request as draft May 30, 2023 02:38
@mdedetrich
Copy link
Contributor

i want to add some random tests against JsonFraming.

Perfect thanks! Such tests should definitely be merged before 1.0.0 if they are ready in time to give us extra confidence.

@mdedetrich mdedetrich added the performance Related to performance label Jun 17, 2023
@mdedetrich
Copy link
Contributor

@He-Pin I am adding this to 1.1.x milestone

@mdedetrich mdedetrich added this to the 1.1.0 milestone Aug 6, 2023
@He-Pin He-Pin marked this pull request as ready for review August 11, 2023 16:13
@He-Pin He-Pin changed the title =str Skip parsing when buffer size is 0. =str Skip parsing when buffer size < 2 Aug 11, 2023
Copy link
Contributor

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -115,20 +115,21 @@ import pekko.util.ByteString
private def seekObject(): Boolean = {
completedObject = false
val bufSize = buffer.length
if (bufSize > 1) {
Copy link
Member Author

@He-Pin He-Pin Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a {} is minimal 2 bytes and need to skip the blank char too

@He-Pin He-Pin requested a review from mdedetrich August 11, 2023 16:16
@He-Pin He-Pin changed the title =str Skip parsing when buffer size < 2 =str Skip parsing when buffer size < 1 Aug 11, 2023
@He-Pin He-Pin force-pushed the jsonObject branch 2 times, most recently from c1bbfbb to 0492ad5 Compare August 11, 2023 16:37
@He-Pin He-Pin requested a review from pjfanning August 11, 2023 16:38
Copy link
Contributor

@mdedetrich mdedetrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin
Copy link
Member Author

He-Pin commented Aug 11, 2023

The error is unrelated.

@He-Pin He-Pin merged commit 8bb19b3 into apache:main Aug 11, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Related to performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants