| 73 | }; |
| 74 | |
| 75 | static void SetMaxOpenFiles(leveldb::Options *options) { |
| 76 | // On most platforms the default setting of max_open_files (which is 1000) |
| 77 | // is optimal. On Windows using a large file count is OK because the handles |
| 78 | // do not interfere with select() loops. On 64-bit Unix hosts this value is |
| 79 | // also OK, because up to that amount LevelDB will use an mmap |
| 80 | // implementation that does not use extra file descriptors (the fds are |
| 81 | // closed after being mmap'ed). |
| 82 | // |
| 83 | // Increasing the value beyond the default is dangerous because LevelDB will |
| 84 | // fall back to a non-mmap implementation when the file count is too large. |
| 85 | // On 32-bit Unix host we should decrease the value because the handles use |
| 86 | // up real fds, and we want to avoid fd exhaustion issues. |
| 87 | // |
| 88 | // See PR #12495 for further discussion. |
| 89 | |
| 90 | int default_open_files = options->max_open_files; |
| 91 | #ifndef WIN32 |
| 92 | if (sizeof(void*) < 8) { |
| 93 | options->max_open_files = 64; |
| 94 | } |
| 95 | #endif |
| 96 | LogPrint(BCLog::LEVELDB, "LevelDB using max_open_files=%d (default=%d)\n", |
| 97 | options->max_open_files, default_open_files); |
| 98 | } |
| 99 | |
| 100 | static leveldb::Options GetOptions(size_t nCacheSize) |
| 101 | { |