| 30 | } |
| 31 | |
| 32 | static void SetMaxOpenFiles(leveldb::Options *options) { |
| 33 | // On most platforms the default setting of max_open_files (which is 1000) |
| 34 | // is optimal. On Windows using a large file count is OK because the handles |
| 35 | // do not interfere with select() loops. On 64-bit Unix hosts this value is |
| 36 | // also OK, because up to that amount LevelDB will use an mmap |
| 37 | // implementation that does not use extra file descriptors (the fds are |
| 38 | // closed after being mmaped). |
| 39 | // |
| 40 | // Increasing the value beyond the default is dangerous because LevelDB will |
| 41 | // fall back to a non-mmap implementation when the file count is too large. |
| 42 | // On 32-bit Unix host we should decrease the value because the handles use |
| 43 | // up real fds, and we want to avoid fd exhaustion issues. |
| 44 | // |
| 45 | // See PR #12495 for further discussion. |
| 46 | |
| 47 | int default_open_files = options->max_open_files; |
| 48 | #ifndef WIN32 |
| 49 | if (sizeof(void*) < 8) { |
| 50 | options->max_open_files = 64; |
| 51 | } |
| 52 | #endif |
| 53 | LogPrintf("LevelDB using max_open_files=%d (default=%d)\n", |
| 54 | options->max_open_files, default_open_files); |
| 55 | } |
| 56 | |
| 57 | static leveldb::Options GetOptions(size_t nCacheSize) |
| 58 | { |