Skip to content

Conversation

@yuzawa-san
Copy link
Contributor

What

  • i was doing some more flame graph analysis on my deployment of kafka-connect and found some hotspots in the AvroData and ProtobufData classes, specifically on their toConnectData and fromConnectData implementations.
  • these loops are quite hot and will benefit from simple iteration.
  • additionally, i was able to presize some of the collections.
  • i have another PR which optimizes the protobuf field hasField/getField which builds on this work.
  • i also have a change in kafka for that Schema iteration MINOR: Optimize Struct.validate() field iteration apache/kafka#21281

cpu flamecharts (inset):
image
image

Checklist

Please answer the questions with Y, N or N/A if not applicable.

  • [N] Contains customer facing changes? Including API/behavior changes
  • [N] Is this change gated behind config(s)?
    • List the config(s) needed to be set to enable this change
  • [N/A] Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required
  • [N] Does this change require modifying existing system tests or adding new system tests?
    • If so, include tracking information for the system test changes
  • [N] Must this be released together with other change(s), either in this repo or another one?
    • If so, please include the link(s) to the changes that must be released together

References

JIRA: N/A

Test & Review

ran test suite

Open questions / Follow-ups

@yuzawa-san yuzawa-san requested a review from a team as a code owner January 20, 2026 19:50
Copilot AI review requested due to automatic review settings January 20, 2026 19:50
@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
✅ yuzawa-san
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@yuzawa-san yuzawa-san changed the title minor: optimize loops + presize in to/fromConnectedData minor: optimize loops + presize in to/fromConnectData Jan 20, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes performance in hot paths of Kafka Connect converters by improving loop iteration patterns and presizing collections.

Changes:

  • Converted enhanced for-loops to indexed loops in fromConnectData and toConnectData methods across AvroData, ProtobufData, and JsonSchemaData classes
  • Presized ArrayList allocations where collection sizes are known in ProtobufData

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
avro-data/src/main/java/io/confluent/connect/avro/AvroData.java Optimized field iteration loops in fromConnectData and toConnectData methods by converting enhanced for-loops to indexed loops
protobuf-converter/src/main/java/io/confluent/connect/protobuf/ProtobufData.java Presized ArrayList collections for ARRAY and MAP cases, and optimized field iteration loops in fromConnectData and toConnectData methods
json-schema-converter/src/main/java/io/confluent/connect/json/JsonSchemaData.java Optimized field iteration loops in fromConnectData method for union and struct handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant