Skip to content

Tuning pool concurrency#3432

Closed
horizonzy wants to merge 11 commits intoapache:masterfrom
horizonzy:tuning-pool-concurrency
Closed

Tuning pool concurrency#3432
horizonzy wants to merge 11 commits intoapache:masterfrom
horizonzy:tuning-pool-concurrency

Conversation

@horizonzy
Copy link
Member

Descriptions of the changes in this PR:
This is a patch #3001. Consider unpooled direct memory on DbLedgerStorage.

@horizonzy
Copy link
Member Author

@hangc0276 hangc0276 added this to the 4.16.0 milestone Jul 28, 2022
Comment on lines +3875 to +3884
Object writeCacheConf = this.getProperty(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB);
if (writeCacheConf instanceof Number) {
writeCacheMb = ((Number) writeCacheConf).longValue();
} else if (writeCacheConf == null) {
writeCacheMb = DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB;
} else if (StringUtils.isEmpty(this.getString(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB))) {
writeCacheMb = DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB;
} else {
writeCacheMb = this.getLong(DbLedgerStorage.WRITE_CACHE_MAX_SIZE_MB);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all this can be done better by moving

        long writeCacheMaxSize = getLongVariableOrDefault(conf, WRITE_CACHE_MAX_SIZE_MB,
                DEFAULT_WRITE_CACHE_MAX_SIZE_MB) * MB;
        long readCacheMaxSize = getLongVariableOrDefault(conf, READ_AHEAD_CACHE_MAX_SIZE_MB,
                DEFAULT_READ_CACHE_MAX_SIZE_MB) * MB;
        boolean directIOEntryLogger = getBooleanVariableOrDefault(conf, DIRECT_IO_ENTRYLOGGER, false);

and related config magic out of DbLedgerStorage into the ServerConfig
and then all you'd need to do is something like this.getWriteCacheMaxSize()

Copy link
Member Author

@horizonzy horizonzy Jul 29, 2022

Choose a reason for hiding this comment

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

Good idea.

Copy link
Member

Choose a reason for hiding this comment

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

Good suggestion, I green with @dlg99

  1. move DbLedgerStorage.DEFAULT_WRITE_CACHE_MAX_SIZE_MB to ServerConfiguration.DEFAULT_WRITE_CACHE_MAX_SIZE_MB

  2. use new code

long writeCacheMaxSize = getLongVariableOrDefault(conf, WRITE_CACHE_MAX_SIZE_MB, conf.getAllocatorPoolingConcurrency()) * MB; 
long readCacheMaxSize = getLongVariableOrDefault(conf, READ_AHEAD_CACHE_MAX_SIZE_MB, conf.getAllocatorPoolingConcurrency()) * MB;

instead of

long writeCacheMaxSize = getLongVariableOrDefault(conf, WRITE_CACHE_MAX_SIZE_MB, DEFAULT_WRITE_CACHE_MAX_SIZE_MB) * MB; 
long readCacheMaxSize = getLongVariableOrDefault(conf, READ_AHEAD_CACHE_MAX_SIZE_MB, DEFAULT_READ_CACHE_MAX_SIZE_MB) * MB;

Copy link
Member

@StevenLuMT StevenLuMT left a comment

Choose a reason for hiding this comment

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

can you add a testcase to cover the new function?

log.info(" - Number of directories: {}", numberOfDirs);
log.info(" - Write cache size: {} MB", writeCacheMaxSize / MB);
log.info(" - Read Cache: {} MB", readCacheMaxSize / MB);
log.info(" - Write cache size: {} MB", writeCacheMaxSize / 1024 / 1024);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we define MB ?

public int getAllocatorPoolingConcurrency() {
long writeCacheSize = this.getWriteCacheMaxSize();
long readCacheSize = this.getReadCacheMaxSize();
long availableDirectMemory = PlatformDependent.maxDirectMemory() - writeCacheSize - readCacheSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use PlatformDependent.estimateMaxDirectMemory() instead of PlatformDependent.maxDirectMemory(). Please refer to: #2989

Copy link
Contributor

Choose a reason for hiding this comment

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

In dbLedgerStorage,

  • If we use DefaultEntryLogger, only the whole write-cache will be allocated at one time in the init state, and the read-cache will be allocated on-demand.
  • If we use DirectEnryLogger, both the write-cache and the read-cache are allocated on-demand.

So I think we'd better keep the default implementation.

@hangc0276 hangc0276 modified the milestones: 4.16.0, 4.17.0 Jul 31, 2022
@StevenLuMT
Copy link
Member

fix old workflow,please see #3455 for detail

@horizonzy horizonzy closed this Feb 17, 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