Skip to content

DeadLetterQueueUtils#extractSegmentId improvement: replace split with index of and substring methods.#18874

Merged
mashhurs merged 2 commits intoelastic:mainfrom
mashhurs:improve-dlq-segmentid-fetch
Apr 7, 2026
Merged

DeadLetterQueueUtils#extractSegmentId improvement: replace split with index of and substring methods.#18874
mashhurs merged 2 commits intoelastic:mainfrom
mashhurs:improve-dlq-segmentid-fetch

Conversation

@mashhurs
Copy link
Copy Markdown
Contributor

@mashhurs mashhurs commented Mar 23, 2026

Release notes

What does this PR do?

DLQ flush operation is heavy, under the hood DeadLetterQueueUtils#extractSegmentId will be called. The String#split is also CPU intensive that internally utilizes Pattern#compile. Since the logic is simple, it can be replaceable with indexOf and substring.

Why is it important/What is the impact to the user?

A bit performance improvement when using DLQ.

Checklist

  • My code follows the style guidelines of this project
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

  • [ ]

How to test this PR locally

Functionality test can be done by enabling DLQ and changing its settings, such as make size small to make DLQ full.
But performance measurement is a bit hard on powerful machines, so here is the benchmark - #18883

Related issues

Use cases

Screenshots

Logs

@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • run exhaustive tests : Run the exhaustive tests Buildkite pipeline.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 23, 2026

This pull request does not have a backport label. Could you fix it @mashhurs? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@mashhurs mashhurs marked this pull request as draft March 23, 2026 18:10
@andsel
Copy link
Copy Markdown
Contributor

andsel commented Mar 24, 2026

FYI I've created #18883 to benchmark the various solutions.

@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

History

@mashhurs mashhurs marked this pull request as ready for review March 25, 2026 21:47
@mashhurs mashhurs self-assigned this Mar 25, 2026
@mashhurs mashhurs requested a review from yaauie March 25, 2026 21:56
Copy link
Copy Markdown
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

🚀

@mashhurs mashhurs added backport-active-all Automated backport with mergify to all the active branches backport-8.19 Automated backport to the 8.19 branch backport-9.2 Automated backport to the 9.2 branch backport-9.3 Automated backport to the 9.3 branch and removed backport-active-all Automated backport with mergify to all the active branches labels Apr 7, 2026
@mashhurs mashhurs merged commit 8d7a5a3 into elastic:main Apr 7, 2026
17 checks passed
mergify bot pushed a commit that referenced this pull request Apr 7, 2026
… index of and substring methods. (#18874)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)
mergify bot pushed a commit that referenced this pull request Apr 7, 2026
… index of and substring methods. (#18874)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)
mergify bot pushed a commit that referenced this pull request Apr 7, 2026
… index of and substring methods. (#18874)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)
@mashhurs
Copy link
Copy Markdown
Contributor Author

mashhurs commented Apr 7, 2026

@Mergifyio backport 9.4

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Apr 7, 2026

backport 9.4

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Apr 7, 2026
… index of and substring methods. (#18874)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)
mashhurs added a commit that referenced this pull request Apr 8, 2026
… index of and substring methods. (#18874) (#18958)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)

Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
mashhurs added a commit that referenced this pull request Apr 8, 2026
… index of and substring methods. (#18874) (#18959)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)

Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
mashhurs added a commit that referenced this pull request Apr 8, 2026
… index of and substring methods. (#18874) (#18960)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)

Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
mashhurs added a commit that referenced this pull request Apr 8, 2026
… index of and substring methods. (#18874) (#18961)

* DeadLetterQueueUtils: avoid using heavy split operation, replace it with simple index of and substring methods.

* Handle exception case if file name doesn't end with .log. Add unit test cases.

(cherry picked from commit 8d7a5a3)

Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.19 Automated backport to the 8.19 branch backport-9.2 Automated backport to the 9.2 branch backport-9.3 Automated backport to the 9.3 branch performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants