Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group writing for per bookie client #33

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

hangc0276
Copy link
Owner

@hangc0276 hangc0276 commented Mar 25, 2023

Motivation

When the BookKeeper client writes an entry to the BookKeeper server, it runs with the following steps:

  • Step 1: Initiate a PendingAddOp object.
  • Step 2: For each replica, select a bookie client channel according to the ledgerId
  • Step 3: Write the entry to the bookie client channel, and flush it.
  • Step 4: The entry was added to Netty's pending queue, and processed with the configured Netty pipeline, such as bookieProtoEncoder, lengthbasedframedecoder, and consolidation
  • Step 5: Waiting for the written response

If the bookie client writes small entries with high ops and the Netty's pending queue will be full and the Netty thread will be busy with processing entries and flushing them into the socket channel. The CPU will switch between the user mode and the kernel mode in high frequency.

apache#3383 introduced Netty channel flushes consolidation to mitigate syscall overhead. But it can not reduce the overhead on the Netty threads.

We can tune it one Step 3 to group the small entries into one ByteBuf and flush it into the Netty pending queue when conditions are met.

Design

When a new entry comes to the bookie client channel, we add it into one ByteBuf and check whether the ByteBuf exceeds the max threshold, the default is 1MB.

In order to avoid entry staying in the Bookie client channel ByteBuf for a long time causing high write latency, we schedule a timer task to flush the ByteBuf every 1 ms.

Performance

We test the write performance on my laptop with the following command.

bin/benchmark writes -ensemble 1 -quorum 1 -ackQuorum 1 -ledgers 100 -throttle 300000 -entrysize 60 -useV2 -warmupMessages 1000000

The performance result.

Writer ledgers batched write ops/s non-batched write ops/s improved
1 333238 335970 0%
50 261605 153011 71%
100 260650 126331 100%
500 265628 164393 62%

@hangc0276 hangc0276 force-pushed the chenhang/group_writing_for_perBookieClient branch from 51ce993 to 1891fe2 Compare March 26, 2023 03:32
ZhangJian He and others added 13 commits March 26, 2023 10:27
…pache#3888)

### Motivation
In checkAllLedgers when the ledger no missing fragments, will miss invoke` lh.closeAsync()` to close ledgerHandler, which cause autorecovery not invoke `unregisterLedgerMetadataListener` to release ledger metadata listeners. Heap memory be used too much and maybe will cause OOM;

<img width="1567" alt="image" src="https://user-images.githubusercontent.com/84127069/227937422-1113af68-9bf3-4466-97fa-d9b7cc5d72be.png">


### Changes
1.  Invoke` lh.closeAsync()` when no missing fragments;
### Motivation
There is a critical CVE-2019-10202 in `org.codehaus.jackson:jackson-mapper-asl`

Detailed paths
Introduced through: org.apache.distributedlog:[email protected] › org.apache.hadoop:[email protected] › org.apache.avro:[email protected] › org.codehaus.jackson:[email protected]
Fix: No remediation path available.
Introduced through: org.apache.distributedlog:[email protected] › org.apache.hadoop:[email protected] › com.sun.jersey:[email protected] › org.codehaus.jackson:[email protected]
Fix: No remediation path available.
Introduced through: org.apache.distributedlog:[email protected] › org.apache.hadoop:[email protected] › com.sun.jersey:[email protected] › org.codehaus.jackson:[email protected] › org.codehaus.jackson:[email protected]
Fix: No remediation path available.
Introduced through: org.apache.distributedlog:[email protected] › org.apache.hadoop:[email protected] › com.sun.jersey:[email protected] › org.codehaus.jackson:[email protected] › org.codehaus.jackson:[email protected]
Fix: No remediation path available.

### Changes
Upgrade hadoop-common version from 3.3.4 to 3.3.5 to resolve this CVE
@hangc0276 hangc0276 force-pushed the chenhang/group_writing_for_perBookieClient branch from 00567fd to ab95ba6 Compare April 2, 2023 13:56
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.

2 participants