New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reactivate Google's PickLevelForMemTableOutput() #163
Changes from 2 commits
fa3b500
1d2b42f
44ce95c
7f4c540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,8 @@ static const size_t kL0_StopWritesTrigger = 12; | |
// expensive manifest file operations. We do not push all the way to | ||
// the largest level since that can generate a lot of wasted disk | ||
// space if the same key space is being repeatedly overwritten. | ||
static const int kMaxMemCompactLevel = 2; | ||
// Basho: push to kNumOverlapLevels +1 ... beyond "landing level" | ||
static const int kMaxMemCompactLevel = 3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment states that kMaxMemCompactLevel is kNumOverlapLevels +1, so why not just actually define it to be that value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed as recommended.
|
||
|
||
} // namespace config | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -475,17 +475,18 @@ bool Version::OverlapInLevel(int level, | |
|
||
int Version::PickLevelForMemTableOutput( | ||
const Slice& smallest_user_key, | ||
const Slice& largest_user_key) { | ||
const Slice& largest_user_key, | ||
const int level_limit) { | ||
int level = 0; | ||
#if 0 | ||
#if 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this code is being put back into production, should remove the "#if 1/#endif" conditional compilation statements. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. corrected as recommended
|
||
// test if level 1 m_OverlappedFiles is false, proceded only then | ||
if (!OverlapInLevel(0, &smallest_user_key, &largest_user_key)) { | ||
// Push to next level if there is no overlap in next level, | ||
// and the #bytes overlapping in the level after that are limited. | ||
InternalKey start(smallest_user_key, kMaxSequenceNumber, kValueTypeForSeek); | ||
InternalKey limit(largest_user_key, 0, static_cast<ValueType>(0)); | ||
std::vector<FileMetaData*> overlaps; | ||
while (level < config::kMaxMemCompactLevel) { | ||
while (level < level_limit) { | ||
if (OverlapInLevel(level + 1, &smallest_user_key, &largest_user_key)) { | ||
break; | ||
} | ||
|
@@ -496,6 +497,10 @@ int Version::PickLevelForMemTableOutput( | |
} | ||
level++; | ||
} | ||
// do not waste a move into an overlapped level, breaks | ||
// different performance improvement | ||
if (gLevelTraits[level].m_OverlappedFiles) | ||
level=0; | ||
} | ||
#endif | ||
return level; | ||
|
@@ -1057,6 +1062,15 @@ void VersionSet::MarkFileNumberUsed(uint64_t number) { | |
} | ||
} | ||
|
||
|
||
bool | ||
VersionSet::NeighborCompactionsQuiet(int level) | ||
{ | ||
return((0==level || !m_CompactionStatus[level-1].m_Submitted) | ||
&& !m_CompactionStatus[level+1].m_Submitted); | ||
} // VersionSet::NeighborCompactionsQuiet | ||
|
||
|
||
bool | ||
VersionSet::Finalize(Version* v) | ||
{ | ||
|
@@ -1095,7 +1109,7 @@ VersionSet::Finalize(Version* v) | |
else | ||
{ | ||
// must not have compactions scheduled on neither level below nor level above | ||
compact_ok=(!m_CompactionStatus[level-1].m_Submitted && !m_CompactionStatus[level+1].m_Submitted); | ||
compact_ok=NeighborCompactionsQuiet(level); | ||
} // else | ||
} // if | ||
|
||
|
@@ -1265,7 +1279,7 @@ VersionSet::UpdatePenalty( | |
penalty_score = penalty_score * penalty_score * penalty_score; | ||
|
||
// if no penalty so far, set a minor penalty to the landing | ||
// level to help it flush. because first sorted layer needs to | ||
// level to help it flush. because first sorted layer needs to | ||
// clear before next dump of overlapped files. | ||
if (penalty_score<1.0 && config::kNumOverlapLevels==level) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The builder added the file to table_cache with mutex_ unlocked; is there any possibility that another thread could have referenced the file via the table_cache before we get to this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new file is not added to the manifest until after this routine returns. The “edit” parameter gets set at line 767 with the new file number and its level. No thread can access this file in the table cache because the file number is not known outside this routine. The “edit” object subsequently gets posted to the manifest. That is when the file number becomes visible.