From 8478f380a0fd70081d8943867ea4f627dcd190f0 Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Mon, 25 Nov 2013 22:04:29 -0800 Subject: [PATCH] During benchmarking, I see excessive use of vector.reserve(). Summary: This code path can potentially accumulate multiple important_files for level 0. But for other levels, it should have only one file in the important_files, so it is ok not to reserve excessive space, is it not? Test Plan: make check Reviewers: haobo Reviewed By: haobo CC: reconnect.grayhat, leveldb Differential Revision: https://reviews.facebook.net/D14349 --- db/version_set.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/version_set.cc b/db/version_set.cc index 95db3e477..adee80d04 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -458,7 +458,9 @@ void Version::Get(const ReadOptions& options, // Get the list of files to search in this level FileMetaData* const* files = &files_[level][0]; important_files.clear(); - important_files.reserve(num_files); + if (level == 0) { + important_files.reserve(num_files); + } // Some files may overlap each other. We find // all files that overlap user_key and process them in order from