Skip to content
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

Blob DB: Improve FIFO eviction #3556

Closed
wants to merge 3 commits into from

Conversation

yiwu-arbug
Copy link
Contributor

@yiwu-arbug yiwu-arbug commented Mar 2, 2018

Summary:
Improving blob db FIFO eviction with the following changes,

  • Change blob_dir_size to max_db_size. Take into account SST file size when computing DB size.
  • FIFO now only take into account live sst files and live blob files. It is normal for disk usage to go over max_db_size because there are obsolete sst files and blob files pending deletion.
  • FIFO eviction now also evict TTL blob files that's still open. It doesn't evict non-TTL blob files.
  • If FIFO is triggered, it will pass an expiration and the current sequence number to compaction filter. Compaction filter will then filter inlined keys to evict those with an earlier expiration and smaller sequence number. So call LSM FIFO.
  • Compaction filter also filter those blob indexes where corresponding blob file is gone.
  • Add an event listener to listen compaction/flush event and update sst file size.
  • Implement DB::Close() to make sure base db, as well as event listener and compaction filter, destruct before blob db.
  • More blob db statistics around FIFO.
  • Fix some locking issue when accessing a blob file.

Test Plan:
See the new tests.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has updated the pull request. View: changes, changes since last import

@@ -199,6 +203,9 @@ class BlobDB : public StackableDB {
return NewIterator(options);
}

using rocksdb::StackableDB::Close;
virtual Status Close() override = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anand1976 I think we have a problem now with Close() still being virtual and people override that instead of CloseImpl(). This will make a confusing experience with some DB overriding Close() and others CloseImpl(). Should Close() be made non-virtual? What was the final decision?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree it should be non-virtual.. if people override Close() they can't set closed_ = true and then DBImpl::CloseHelper will always be called in destruction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ignore my comment. This StackableDB class doesn't subclass DBImpl so my comment was wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with @anand1976 and @ajkr. I'm going to implement CloseImpl() not Close(). I'll split the change to another PR for review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no DB::CloseImpl(). The Close()/CloseImpl() pattern was only for the Logger class. Although after talking with @yiwu-arbug and @ajkr it makes sense to have the same pattern in DB as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go ahead with my current PR and wait till changes on DBImpl side to change to use CloseImpl().

@yiwu-arbug yiwu-arbug changed the title Blob DB: Imprvoe FIFO eviction Blob DB: Improve FIFO eviction Mar 5, 2018
@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has updated the pull request. View: changes, changes since last import

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has updated the pull request.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@sagar0 sagar0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me from the BlobDB perspective, subject to the discussion around close/closeimpl. Lets update here with the summary of the discussion that you had with Anand about Close.

@yiwu-arbug
Copy link
Contributor Author

Regarding DB::Close(), @anand1976 will make the change to DBImpl similar to what he did for Logger #3528. Subclasses of StackableDB will need to implement a ::CloseImpl method and the order of execution will be analogous to destructor: derived class's CloseImpl will be called first and then base class's CloseImpl. StackableDB::Close() will be non-virtual and is responsible to call CloseImpl in order, and setting closed_ flag so a second Close() will be noop. I'll leave the implementation here as-is, and wait till the change on DBImpl side and make change to BlobDB accordingly.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yiwu-arbug is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@yiwu-arbug yiwu-arbug deleted the blob_fifo branch March 15, 2018 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants