Skip to content

Backport PR #17050 to 9.0: move Batch deserialization out of the lock#17109

Merged
jsvd merged 1 commit into9.0from
backport_17050_9.0
Feb 17, 2025
Merged

Backport PR #17050 to 9.0: move Batch deserialization out of the lock#17109
jsvd merged 1 commit into9.0from
backport_17050_9.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Backport PR #17050 to 9.0 branch, original message:


currently the deserialization is behind the readBatch's lock, so any large batch will take time deserializing, causing any other Queue writer (e.g. netty executor threads) and any other Queue reader (pipeline worker) to block.

This commit moves the deserialization out of the lock, allowing multiple pipeline workers to deserialize batches concurrently.

To test, edit the generator input to produce 100kb messages, and run:

bin/logstash -e "input { generator { threads => 5 } } output { null {} }" with PQ enabled.

This PR should shows about a 4-5x performance improvement for 10 worker pipeline:

Metric v8.15.5 v8.15.5+pr17050
Events per Second 1031 4971
CPU Usage (for 10 cores) 111.2% 593.1%
Concurrent Deserializations 1 2-5

Currently the deserialization is behind the readBatch's lock, so any large batch will take time deserializing, causing any other Queue writer (e.g. netty executor threads) and any other Queue reader (pipeline worker) to block.

This commit moves the deserialization out of the lock, allowing multiple pipeline workers to deserialize batches concurrently.

- add intermediate batch-holder from `Queue` methods
- make the intermediate batch-holder a private inner class of `Queue` with a descriptive name `SerializedBatchHolder`

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
(cherry picked from commit 637f447)
@elastic-sonarqube
Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

@jsvd jsvd merged commit 39950dc into 9.0 Feb 17, 2025
@jsvd jsvd deleted the backport_17050_9.0 branch February 17, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants