Skip to content

Backport PR #17050 to 8.16: move Batch deserialization out of the lock#17108

Merged
jsvd merged 1 commit into8.16from
backport_17050_8.16
Feb 17, 2025
Merged

Backport PR #17050 to 8.16: move Batch deserialization out of the lock#17108
jsvd merged 1 commit into8.16from
backport_17050_8.16

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Feb 17, 2025

Backport PR #17050 to 8.16 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

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

💚 Build Succeeded

@jsvd jsvd merged commit 4205eb7 into 8.16 Feb 17, 2025
5 checks passed
@jsvd jsvd deleted the backport_17050_8.16 branch February 17, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants