forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit the number of read-only files the POSIX Env will have open.
Background compaction can create an unbounded number of leveldb::RandomAccessFile instances. On 64-bit systems mmap is used and file descriptors are only used beyond a certain number of mmap's. 32-bit systems to not use mmap at all. leveldb::RandomAccessFile does not observe Options.max_open_files so compaction could exhaust the file descriptor limit. This change uses getrlimit to determine the maximum number of open files and limits RandomAccessFile to approximately 20% of that value. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143505556
- Loading branch information
Showing
3 changed files
with
204 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2017 The LevelDB Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. See the AUTHORS file for names of contributors. | ||
|
||
#ifndef STORAGE_LEVELDB_UTIL_ENV_POSIX_TEST_HELPER_H_ | ||
#define STORAGE_LEVELDB_UTIL_ENV_POSIX_TEST_HELPER_H_ | ||
|
||
namespace leveldb { | ||
|
||
class EnvPosixTest; | ||
|
||
// A helper for the POSIX Env to facilitate testing. | ||
class EnvPosixTestHelper { | ||
private: | ||
friend class EnvPosixTest; | ||
|
||
// Set the maximum number of read-only files that will be opened. | ||
// Must be called before creating an Env. | ||
static void SetReadOnlyFDLimit(int limit); | ||
|
||
// Set the maximum number of read-only files that will be mapped via mmap. | ||
// Must be called before creating an Env. | ||
static void SetReadOnlyMMapLimit(int limit); | ||
}; | ||
|
||
} // namespace leveldb | ||
|
||
#endif // STORAGE_LEVELDB_UTIL_ENV_POSIX_TEST_HELPER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters