You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "umisan (via GitHub)" <gi...@apache.org> on 2025/02/16 03:40:46 UTC
[PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
umisan opened a new pull request, #17732:
URL: https://github.com/apache/druid/pull/17732
<!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. -->
<!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. -->
<!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->
<!-- If you are a committer, follow the PR action item checklist for committers:
https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->
### Description
<!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. -->
This PR aims to speed up metadata reading, improving performance during metadata polling.
<!-- Describe your patch: what did you change in code? How did you fix the problem? -->
This patch changes the code to use ObjectReader instead of ObjectMapper when reading multiple JSON objects. Since ObjectReader is slightly faster in this scenario, this change should improve the performance of metadata polling.
[jackson document](https://github.com/FasterXML/jackson-databind/wiki/Serialization-features)
<!--
In each section, please describe design decisions made, including:
- Choice of algorithms
- Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources?
- Class organization and design (how the logic is split between classes, inheritance, composition, design patterns)
- Method organization and design (how the logic is split between methods, parameters and return types)
- Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
-->
<!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
<!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
<!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
#### Release note
<!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users.
If your change doesn't have end user impact, you can skip this section.
For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
-->
Improved: You can now load newly added segments more quickly.
<hr>
##### Key changed/added classes in this PR
* `SqlSegmentsMetadataManager`
<hr>
<!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
This PR has:
- [x] been self-reviewed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2661812065
Thanks a lot, @umisan !
I am really glad to hear that you have enjoyed using Druid.
I look forward to the contributions from you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2662641340
@umisan i didn't find any information about ObjectReader from the link you gave. If the ObjectReader has better performance, what I think is we can apply it to the ingestion module which uses ObjectMapper heavily.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2661336152
> I am considering setting up a test Druid cluster to evaluate this change. However, it's possible that the results will show that this PR doesn't provide meaningful improvements.
@umisan , yes, that's what I fear as well.
I had actually tried out a change to reduce the amount of deserialization done but it did not affect the total polling time at all.
FYI, we have recently merged a segment caching feature in #17653 .
The code in this patch is able to do a delta poll of ~600k segments in just a couple of seconds.
Essentially, it does not fetch segments from the metadata store which have not been updated.
While this does not currently impact the polling time in `SqlSegmentsMetadataManager`,
I intend to plug in the same logic there once I have had time to test out and benchmark the cache changes thoroughly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "umisan (via GitHub)" <gi...@apache.org>.
umisan commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2662708952
@FrankChen021
Sorry, my previous link was incorrect.
Here is the correct link:
https://github.com/fasterxml/jackson-docs/wiki/presentation:-jackson-performance
This document explains that ObjectReader performs better than ObjectMapper.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2661288496
Thanks for creating the PR, @umisan !
Have you been able to compare the performance of this code while polling real segments before and after the change?
In my experience, most of the time in the poll is actually spent in the IO itself rather than the Jackson deserialization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 merged PR #17732:
URL: https://github.com/apache/druid/pull/17732
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "umisan (via GitHub)" <gi...@apache.org>.
umisan commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2661395231
I understand the current situation.
For now, I’m planning to set up a test Druid cluster to test this PR and also to prepare for future contributions. However, I don’t have experience building and running Druid locally, and I can only work on this during weekends, so it will take some time.
Given this, I’m thinking of closing this PR for now. If testing shows that this change provides meaningful improvements, I will reopen it.
Thank you for reviewing my PR and sharing your insights!
Thanks to this amazing open-source project, our team has been able to improve system performance while reducing costs.
Moving forward, I hope to contribute, even if only in a small way, to help improve Druid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2673845141
While the document states that ObjectReader is performant than ObjectMapper, the gain is trivial.
I have a system that consumes messages from Kafka at a regular speed of 900MiB/s, after I replaced the ObjectMapper with ObjectReader as well as applied the `Afterburner` module, I didn't see obvious CPU saving or TPS improvment.
But I think we can still accpet and merge this change as it can be seen a best practice of using jackson.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Using ObjectReader in the SqlSegmentsMetadataManager.doPollSegments (druid)
Posted by "umisan (via GitHub)" <gi...@apache.org>.
umisan commented on PR #17732:
URL: https://github.com/apache/druid/pull/17732#issuecomment-2661312257
@kfaraz
Thanks for reviewing my PR.
Sorry, I haven't tested this change on our Druid cluster yet.
I completely agree with your point that most of the time spent during polling is due to I/O, and the improvement from deserialization optimization might be negligible.
Our Druid cluster has about 1 million segments and takes several minutes to load newly added segments. Unfortunately, we don't have a staging Druid cluster, so I haven't been able to test this change in an environment with a large number of segments.
I am considering setting up a test Druid cluster to evaluate this change. However, it's possible that the results will show that this PR doesn't provide meaningful improvements.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org