Skip to content

[improve] add read rate limter for compaction#3976

Closed
HQebupt wants to merge 1 commit intoapache:masterfrom
HQebupt:addReadRateLimterInCompaction
Closed

[improve] add read rate limter for compaction#3976
HQebupt wants to merge 1 commit intoapache:masterfrom
HQebupt:addReadRateLimterInCompaction

Conversation

@HQebupt
Copy link
Contributor

@HQebupt HQebupt commented May 31, 2023

Motivation

The purpose of this feature is to provide more flexibility and control over the compaction process in the Bookkeeper server by allowing users to configure the read rate of compaction according to their specific requirements.
It adds support for configuring the read rate of compaction in bytes per second.

In our production environment of Bookkeeper, we have set compactionRateByBytes=30M. However, we have observed that it only limits the write speed to disk and does not limit the read speed from disk. In our environment, the continuous saturation of disk IO for reads in compaction is causing issues with data consumption from the disk.

// Set the rate at which compaction will readd entries. The unit is bytes added per second.
 compactionRateByBytes=31457280

image

image

Changes

  • In the GarbageCollectorThread class, a new field compactionReadByteRateLimiter of type RateLimiter is added to control the read rate of compaction.
  • In the ServerConfiguration class, a new configuration property COMPACTION_READ_RATE_BY_BYTES is defined to specify the read rate of compaction in bytes per second.

Master Issue: #8

Comment on lines +625 to 627
long compactSize = meta.getTotalSize() - meta.getRemainingSize();
compactionReadByteRateLimiter.acquire((int) (compactSize));
compactEntryLog(meta);
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, when the compact is in progress, if compactionRateBytes is configured, the compact will be limited when writing the disk. Since read and write are processed strictly serially, the next read needs to wait for the write operation to complete. Does it mean that read is also limited to compactionRateByBytes?

I suspect that your problem here is because the disk read rate is too fast caused by getting entryLogMeta from entryLogFile, you can look at this PR: #2963

@hangc0276 Please help take a look. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

@HQebupt Can you search in your bookie service log to see if there is the following log when the read IO is high: “Extracting entry log meta from entryLogId”

Copy link
Member

Choose a reason for hiding this comment

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

Good catch, please see this comment @HQebupt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wenbingshen It did not help after I cherry pick #2963. We can discuss it when you are available tomorrow.

// Set the rate at which compaction will readd entries. The unit is bytes added per second.
 compactionRateByBytes=31457280

image

image

@hangc0276
Copy link
Contributor

Please check the following two PRs. #3959, #3192

@wenbingshen
Copy link
Member

Please check the following two PRs. #3959, #3192

@HQebupt I think compaction high read IO can be solved by #2963 #3192 and the high write IO can be solved by #3959. Please look at @hangc0276‘s comments.

@HQebupt
Copy link
Contributor Author

HQebupt commented Jun 2, 2023

It works, thank you @wenbingshen @hangc0276 @StevenLuMT I closed the PR.

@HQebupt HQebupt closed this Jun 2, 2023
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.

4 participants