-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Mark more files for periodic compaction during offpeak #12031
Mark more files for periodic compaction during offpeak #12031
Conversation
d07f183
to
16afcb0
Compare
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
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.
AFAIK, the implementation is fine. The tests seem verbose and perhaps not well controlled (changing one variable at a time).
@@ -2230,6 +2231,209 @@ TEST_F(DBTestUniversalCompaction2, PeriodicCompaction) { | |||
ASSERT_EQ(4, output_level); | |||
} | |||
|
|||
TEST_F(DBTestUniversalCompaction2, PeriodicCompactionOffpeak) { |
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.
Is there a significant difference in universal and leveled behavior here? It seems like a lot of duplication (more or less).
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.
From the perspective of picking files based on their age, no. But just wanted to have the coverage on both compaction types.
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.
IMHO, code duplication in tests (more or less) is a greater sin than keeping tests neatly organized by feature. Features interact, so there's no way to be absolutely clean in organization--assuming your tests are interesting and not just a rehash of the implementation; you just put things some place reasonable and respect the greater threats to maintenance burden such as verbosity / unnecessary repetition.
It would probably be different if compaction strategies were pluggable components, but they are deeply integrated.
I appreciate the narrative comments to help future engineers to understand what is being tested and how. Clarity in the "what & why" of a test is most important. :) (Sometimes it's obvious: feature X has its documented effect when turned on and does not when it's turned off.)
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.
Simplified the test for Leveled one, added comment and addressed the feedback in the Universal one.
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.
Do we plan to extend the logic to TTL compaction too?
Random rnd(test::RandomSeed()); | ||
int days = rnd.Uniform(100); | ||
|
||
int periodic_compactions = 0; |
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.
Probably will need atomic_int.
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.
Doesn't compaction picking happen while holding the DB mutex? If so, there would only be a race with the test code if there's a race in executing the periodic compactions.
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.
Yes, compaction picking happens while holding the db mutex. I was worried that the test code can access periodic_compactions
while compaction picking is happening. That seems to be not the case. I guess if TSAN complains about it, it's fine too and it means the test has a bug.
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.
I will leave it without atomic
and see what TSAN says.
@cbi42 Regarding the comment on TTL, no, not at the moment since we are going to start with Zippy first which is Universal. But it's definitely something that we can consider adding in the later PRs. |
26c4fa9
to
4e73db6
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
4e73db6
to
a4944f3
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
a4944f3
to
5060b8a
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
5060b8a
to
ed84fe9
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
2 similar comments
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
2d68d9a
to
a14eb23
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
7490f2a
to
788d092
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
788d092
to
083041e
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
083041e
to
4ccc413
Compare
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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.
LGTM
@jaykorean merged this pull request in 2dab137. |
@jaykorean , thanks for the change. I'd like to try this option in Java application. How can we set this? I see no options in Options nor DBOptions. Thanks |
@sakae-nakajima The option to enable this feature is not exposed in Java API yet. Feel free to try adding it yourself and add me as a reviewer. I'd be more than happy to review the PR. You may also want to try reaching out to the Java API contributors (@adamretter, @alanpaxton and more) for help. Or I will try finding some time later in December or early next year to add it. |
@jaykorean @sakae-nakajima my colleague @alanpaxton has implemented this here - #13148 it is just waiting to be merged by the FB team? |
@adamretter I must have missed it. Let me review and import this to the internal repo. Thanks for the heads up! |
Summary
OffpeakTimeInfo
has been renamed toOffpeakTimeOption
to indicate that it's a user-configurable option. Additionally, a new struct,OffpeakTimeInfo
, has been introduced, which includes two fields:is_now_offpeak
andseconds_till_next_offpeak_start
. This change prevents the need to parse thedaily_offpeak_time_utc
string twice.OffpeakTimeInfo
struct, such aselapsed_seconds
andtotal_seconds
, as needed for further optimization.VersionStorageInfo::ComputeFilesMarkedForPeriodicCompaction()
, we've adjusted theallowed_time_limit
to include files that are expected to expire by the next offpeak start.Test Plan
Unit Tests added
DBCompactionTest::LevelPeriodicCompactionOffpeak
for LeveledDBTestUniversalCompaction2::PeriodicCompaction
for Universal