diff --git a/repertory/librepertory/src/utils/utils.cpp b/repertory/librepertory/src/utils/utils.cpp index eeb0b296..5f9308b0 100644 --- a/repertory/librepertory/src/utils/utils.cpp +++ b/repertory/librepertory/src/utils/utils.cpp @@ -19,6 +19,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "rocksdb/table.h" + #include "utils/utils.hpp" #include "app_config.hpp" @@ -38,12 +40,9 @@ void calculate_allocation_size(bool directory, std::uint64_t file_size, return; } - if (file_size > allocation_size) { - allocation_size = file_size; - } - allocation_size = - utils::divide_with_ceiling(allocation_size, WINFSP_ALLOCATION_UNIT) * + utils::divide_with_ceiling(std::max(file_size, allocation_size), + WINFSP_ALLOCATION_UNIT) * WINFSP_ALLOCATION_UNIT; allocation_meta_size = std::to_string(allocation_size); } @@ -51,8 +50,8 @@ void calculate_allocation_size(bool directory, std::uint64_t file_size, auto create_rocksdb( const app_config &cfg, const std::string &name, const std::vector &families, - std::vector &handles, - bool clear) -> std::unique_ptr { + std::vector &handles, bool clear) + -> std::unique_ptr { REPERTORY_USES_FUNCTION_NAME(); auto db_dir = utils::path::combine(cfg.get_data_directory(), {"db"}); @@ -67,11 +66,18 @@ auto create_rocksdb( "failed to remove " + name + " db|" + path); } + rocksdb::BlockBasedTableOptions table_options{}; + table_options.block_cache = + rocksdb::NewLRUCache(2ULL * 1024ULL * 1024LL * 1024LL); + table_options.cache_index_and_filter_blocks = true; + rocksdb::Options options{}; options.create_if_missing = true; options.create_missing_column_families = true; options.db_log_dir = cfg.get_log_directory(); options.keep_log_file_num = 10; + options.table_factory.reset( + rocksdb::NewBlockBasedTableFactory(table_options)); rocksdb::TransactionDB *ptr{}; auto status = rocksdb::TransactionDB::Open(