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

Method AsyncFeatureStoreMgr

serving/processor/storage/feature_store_mgr.cc:147–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145} // namespace
146
147AsyncFeatureStoreMgr::AsyncFeatureStoreMgr(ModelConfig* config, WorkFn fn) :
148 stop_(false),
149 thread_num_(config->read_thread_num),
150 update_thread_num_(config->update_thread_num),
151 active_thread_index_(0),
152 active_update_thread_index_(0) {
153 if (thread_num_ < 1 || thread_num_ > MANAGER_MAX_THREAD_NUM) {
154 LOG(FATAL) << "Invalid IO thread num, required [1, 96], get "
155 << thread_num_;
156 }
157
158 if (update_thread_num_ < 1 ||
159 update_thread_num_ > MANAGER_MAX_UPDATE_THREAD_NUM) {
160 LOG(FATAL) << "Invalid IO thread num, required [1, 16], get "
161 << update_thread_num_;
162 }
163
164 task_queues_.resize(thread_num_);
165 threads_.resize(thread_num_);
166 mutex_.resize(thread_num_);
167 cv_.resize(thread_num_);
168 store_.resize(thread_num_);
169 for (int i = 0; i < thread_num_; ++i) {
170 mutex_[i] = new std::mutex();
171 cv_[i] = new std::condition_variable();
172 ready_[i] = false;
173 sleeping_[i] = false;
174 store_[i] = CreateFeatureStore(config);
175 threads_[i].reset(new std::thread(!fn? &ThreadRun : fn, this, i, false));
176 }
177
178 update_task_queues_.resize(update_thread_num_);
179 update_threads_.resize(update_thread_num_);
180 update_mutex_.resize(update_thread_num_);
181 update_cv_.resize(update_thread_num_);
182 update_store_.resize(update_thread_num_);
183 for (int i = 0; i < update_thread_num_; ++i) {
184 update_mutex_[i] = new std::mutex();
185 update_cv_[i] = new std::condition_variable();
186 update_ready_[i] = false;
187 update_sleeping_[i] = false;
188 update_store_[i] = CreateFeatureStore(config);
189 update_threads_[i].reset(new std::thread(!fn ? &ThreadRun : fn, this, i, true));
190 }
191}
192
193AsyncFeatureStoreMgr::~AsyncFeatureStoreMgr() {
194 // stop all IO threads

Callers

nothing calls this directly

Calls 3

CreateFeatureStoreFunction · 0.85
resizeMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected