Skip to content

MINOR: fix the header size calculation - #12916

Closed
showuon wants to merge 1 commit into
apache:trunkfrom
showuon:headerSize
Closed

showuon wants to merge 1 commit into
apache:trunkfrom
showuon:headerSize

Conversation

@showuon

@showuon showuon commented Nov 29, 2022

Copy link
Copy Markdown
Member

In #12890 , we have an improvement for the ObjectSerializationCache in request/response header, but the header size is not correct calculated. Fix it and add size check tests.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

// We derive the header version from the request api version, so we read that first.
// The request api version is part of `RequestHeaderData`, so we reset the buffer position after the read.
int position = buffer.position();
int requestHeaderSize = buffer.remaining();

@showuon showuon Nov 29, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not correct. The buffer in the payload buffer is actually [header + message] . So, if we do buffer.remaining() here, we'll get the wrong header size. It can be confirmed via unit tests, ex: RequestResponseTest#testSerializeWithHeader. Fix it by removing the cache setting here.

@showuon

showuon commented Nov 29, 2022

Copy link
Copy Markdown
Member Author

@divijvaidya @mimaison , please take a look. Thanks.

@divijvaidya

Copy link
Copy Markdown
Member

Thanks for catching this Luke! Bad of me to assume that buffer will be header data only. Seems like we incrementally read the buffer.

ResponseHeader size is also modified at #12890, we need to revert that back too. Perhaps revert the entire commit? I can create a new one which would fix the performance problem (not using ObjectSerialization cache when it isn't required) and yet keep the correct semantics.

After the revert, we can use this PR to add tests.

@mimaison

Copy link
Copy Markdown
Member

@divijvaidya Yeah I missed that too!
Can you make a PR to address the issues? If so we probably don't need to revert #12890

@showuon

showuon commented Nov 29, 2022

Copy link
Copy Markdown
Member Author

Making another PR to address the issue is a good option. Let's fix this issue together! :)

@divijvaidya

Copy link
Copy Markdown
Member

I used a different approach to calculate the size in the PR #12917
Instead of using buffer.remaining() which provide the un-traversed suffix of the buffer (hence representing the api message body), we need the traversed buffer during the parsing stage. I find that by keeping track of buffer pointers before and after the parse.

@showuon @mimaison Please check the corresponding PR for details.

@showuon

showuon commented Nov 30, 2022

Copy link
Copy Markdown
Member Author

Close this PR and fix in #12917

@showuon showuon closed this Nov 30, 2022
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

Successfully merging this pull request may close these issues.

3 participants