Skip to content

KAFKA-14414: Modify approach to calculate size of request header - #12917

Merged
mimaison merged 1 commit into
apache:trunkfrom
divijvaidya:fix-KAFKA-14414
Nov 30, 2022
Merged

mimaison merged 1 commit into
apache:trunkfrom
divijvaidya:fix-KAFKA-14414

Conversation

@divijvaidya

Copy link
Copy Markdown
Member

#12890 introduced the notion of calculating (and caching) the size for the request header during the first parse operation. This prevents re-calculation and hence, improves CPU usage for produce workload.

However, @showuon found a bug in calculation of size in that PR mentioned at #12916

This PR modifies the (incorrect!) approach we took earlier to calculate the header size and replaces it with another approach while still avoiding re-calculation of request header size.

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks for the improvement.

Comment on lines +132 to +136
// Size of header is calculated by the shift in the position of buffer's start position during parsing.
// Prior to parsing, the buffer's start position points to header data and after the parsing operation
// the buffer's start position points to api message. For more information on how the buffer is
// constructed, see RequestUtils#serialize()
header.size = Math.max(buffer.position() - bufferStartPositionForHeader, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice improvement! Thanks.

@mimaison mimaison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@mimaison
mimaison merged commit b2d8354 into apache:trunk Nov 30, 2022
honshu added a commit to confluentinc/kafka that referenced this pull request Nov 30, 2022
* apache-kafka/trunk: (31 commits)
  KAFKA-14413: Separate MirrorMaker configurations for each connector (apache#12899)
  MINOR: Fix config documentation formatting (apache#12921)
  KAFKA-13731: Allow standalone workers to be started without providing any connector configurations (apache#11890)
  MINOR: Fix docs in security.html (apache#12851)
  MINOR: Remove config/kraft/README.md from rat exclusion list (apache#12923)
  MINOR: Update Gradle to 7.6 (apache#12918)
  KAFKA-14414: Fix request/response header size calculation (apache#12917)
  KAFKA-14339 : Do not perform producerCommit on serializationError when trying offsetWriter flush (apache#12920)
  KAFKA-14367; Add `JoinGroup` to the new `GroupCoordinator` interface (apache#12845)
  MINOR: buildoutput.log should be under the `build` directory (apache#12919)
  ...
@divijvaidya
divijvaidya deleted the fix-KAFKA-14414 branch December 15, 2022 09:37
guozhangwang pushed a commit to guozhangwang/kafka that referenced this pull request Jan 25, 2023
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