| 112 | }; |
| 113 | |
| 114 | static void SetMaxOpenFiles(leveldb::Options *options) { |
| 115 | // On most platforms the default setting of max_open_files (which is 1000) |
| 116 | // is optimal. On Windows using a large file count is OK because the handles |
| 117 | // do not interfere with select() loops. On 64-bit Unix hosts this value is |
| 118 | // also OK, because up to that amount LevelDB will use an mmap |
| 119 | // implementation that does not use extra file descriptors (the fds are |
| 120 | // closed after being mmap'ed). |
| 121 | // |
| 122 | // Increasing the value beyond the default is dangerous because LevelDB will |
| 123 | // fall back to a non-mmap implementation when the file count is too large. |
| 124 | // On 32-bit Unix host we should decrease the value because the handles use |
| 125 | // up real fds, and we want to avoid fd exhaustion issues. |
| 126 | // |
| 127 | // See PR #12495 for further discussion. |
| 128 | |
| 129 | int default_open_files = options->max_open_files; |
| 130 | #ifndef WIN32 |
| 131 | if (sizeof(void*) < 8) { |
| 132 | options->max_open_files = 64; |
| 133 | } |
| 134 | #endif |
| 135 | LogDebug(BCLog::LEVELDB, "LevelDB using max_open_files=%d (default=%d)\n", |
| 136 | options->max_open_files, default_open_files); |
| 137 | } |
| 138 | |
| 139 | static leveldb::Options GetOptions(size_t nCacheSize) |
| 140 | { |