MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SSDHashKV

Method SSDHashKV

tensorflow/core/framework/embedding/ssd_hash_kv.h:141–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139class SSDHashKV : public KVInterface<K, V> {
140 public:
141 explicit SSDHashKV(const std::string& path,
142 FeatureDescriptor<V>* feat_desc)
143 : feat_desc_(feat_desc) {
144 path_ = io::JoinPath(
145 path, "ssd_kv_" + std::to_string(Env::Default()->NowMicros()) + "_");
146 hash_map_.max_load_factor(0.8);
147 hash_map_.set_empty_key_and_value(EMPTY_KEY, nullptr);
148 hash_map_.set_counternum(16);
149 hash_map_.set_deleted_key(DELETED_KEY);
150 evict_file_set_.max_load_factor(0.8);
151 evict_file_set_.set_empty_key_and_value(EMPTY_KEY, -1);
152 evict_file_set_.set_counternum(16);
153 evict_file_set_.set_deleted_key(DELETED_KEY);
154
155 is_async_compaction_ = true;
156 TF_CHECK_OK(ReadBoolFromEnvVar("TF_SSDHASH_ASYNC_COMPACTION", true,
157 &is_async_compaction_));
158
159 std::string io_scheme = "mmap_and_madvise";
160 TF_CHECK_OK(ReadStringFromEnvVar(
161 "TF_SSDHASH_IO_SCHEME", "mmap_and_madvise", &io_scheme));
162 emb_file_creator_ = EmbFileCreatorFactory::Create(io_scheme);
163 EmbFile* ef = emb_file_creator_->Create(path_, current_version_, BUFFER_SIZE);
164 emb_files_.emplace_back(ef);
165
166 if (!is_async_compaction_) {
167 LOG(INFO) <<
168 "Use Sync Compactor in SSDHashKV of Multi-tier Embedding Storage!";
169 compaction_fn_ = [this](){Compaction();};
170 check_buffer_fn_ = [this](){CheckBuffer();};
171 save_kv_fn_ = [this](K key, const void* value_ptr,
172 bool is_compaction=false) {
173 SaveKV(key, value_ptr, is_compaction);
174 };
175 } else {
176 LOG(INFO) <<
177 "Use Async Compactor in SSDHashKV of Multi-tier Embedding Storage!";
178 compaction_fn_ = [](){};
179 check_buffer_fn_ = [this](){CheckBufferAsync();};
180 save_kv_fn_ = [this](K key, const void* value_ptr,
181 bool is_compaction=false) {
182 SaveKVAsync(key, value_ptr, is_compaction);
183 };
184 compaction_thread_ = Env::Default()->StartThread(
185 ThreadOptions(), "COMPACTION", [this]() {
186 CompactionThread();
187 });
188 }
189 }
190
191 void Init() {
192 val_len_ = feat_desc_->data_bytes();

Callers

nothing calls this directly

Calls 11

to_stringFunction · 0.85
DefaultFunction · 0.85
ReadStringFromEnvVarFunction · 0.85
ThreadOptionsClass · 0.85
JoinPathFunction · 0.50
ReadBoolFromEnvVarFunction · 0.50
CreateFunction · 0.50
NowMicrosMethod · 0.45
CreateMethod · 0.45
emplace_backMethod · 0.45
StartThreadMethod · 0.45

Tested by

no test coverage detected