-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue=1258, Tcache support block-level cache evict
- Loading branch information
caijieming
committed
May 18, 2017
1 parent
f15ac00
commit 72a31b8
Showing
10 changed files
with
1,372 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright (c) 2015, Baidu.com, Inc. All Rights Reserved | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef STOREAGE_LEVELDB_UTIL_BLOCK_CACHE_H | ||
#define STOREAGE_LEVELDB_UTIL_BLOCK_CACHE_H | ||
#include "leveldb/status.h" | ||
#include "leveldb/options.h" | ||
|
||
namespace leveldb { | ||
///////////////////////////////////////////// | ||
// Tcache | ||
///////////////////////////////////////////// | ||
uint64_t kBlockSize = 8192UL; | ||
uint64_t kDataSetSize = 134217728UL; | ||
uint64_t kFidBatchNum = 200000UL; | ||
uint64_t kCacheSize = 350000000000UL; | ||
uint64_t kMetaBlockSize = 2000UL; | ||
uint64_t kMetaTableSize = 500UL; | ||
uint64_t kWriteBufferSize = 1048576UL; | ||
|
||
struct BlockCacheOptions { | ||
Options opts; | ||
std::string cache_dir; | ||
uint64_t block_size; | ||
uint64_t dataset_size; | ||
uint64_t fid_batch_num; | ||
uint64_t cache_size; | ||
uint64_t dataset_num; | ||
uint64_t meta_block_cache_size; | ||
uint64_t meta_table_cache_size; | ||
uint64_t write_buffer_size; | ||
Env* env; | ||
|
||
BlockCacheOptions() | ||
: block_size(kBlockSize), | ||
dataset_size(kDataSetSize), | ||
fid_batch_num(kFidBatchNum), | ||
cache_size(kCacheSize), | ||
meta_block_cache_size(kMetaBlockSize), | ||
meta_table_cache_size(kMetaTableSize), | ||
write_buffer_size(kWriteBufferSize), | ||
env(NULL) { | ||
dataset_num = cache_size / dataset_size + 1; | ||
} | ||
}; | ||
|
||
class BlockCacheWritableFile; | ||
class BlockCacheRandomAccessFile; | ||
class BlockCacheImpl; | ||
|
||
class BlockCacheEnv : public EnvWrapper { | ||
public: | ||
BlockCacheEnv(Env* base); | ||
|
||
~BlockCacheEnv(); | ||
|
||
virtual Status FileExists(const std::string& fname); | ||
|
||
virtual Status GetChildren(const std::string& path, | ||
std::vector<std::string>* result); | ||
|
||
virtual Status DeleteFile(const std::string& fname); | ||
|
||
virtual Status CreateDir(const std::string& name); | ||
|
||
virtual Status DeleteDir(const std::string& name); | ||
|
||
virtual Status CopyFile(const std::string& from, | ||
const std::string& to); | ||
|
||
virtual Status GetFileSize(const std::string& fname, uint64_t* size); | ||
|
||
virtual Status RenameFile(const std::string& src, const std::string& target); | ||
|
||
virtual Status LockFile(const std::string& fname, FileLock** lock); | ||
|
||
virtual Status UnlockFile(FileLock* lock); | ||
|
||
virtual Status NewSequentialFile(const std::string& fname, | ||
SequentialFile** result); // never cache log | ||
|
||
// cache relatively | ||
virtual Status NewRandomAccessFile(const std::string& fname, | ||
RandomAccessFile** result); // cache Pread | ||
|
||
virtual Status NewWritableFile(const std::string& fname, | ||
WritableFile** result); // cache Append | ||
Status LoadCache(const BlockCacheOptions& opts, const std::string& cache_dir); | ||
|
||
private: | ||
std::vector<BlockCacheImpl*> cache_vec_; | ||
Env* dfs_env_; | ||
}; | ||
|
||
Env* NewBlockCacheEnv(Env* base); | ||
|
||
} // leveldb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.