@@ -205,23 +205,21 @@ Status BasicManager::Create(Options options,
205205 manager->reset (new BasicManager (
206206 options.env , options.num_load_threads , options.num_unload_threads ,
207207 options.max_num_load_retries , options.load_retry_interval_micros ,
208- options. flush_filesystem_caches , std::move (options.resource_tracker ),
209- options. servable_event_bus , std::move (options.pre_load_hook )));
208+ std::move (options.resource_tracker ), options. servable_event_bus ,
209+ std::move (options.pre_load_hook )));
210210 return Status::OK ();
211211}
212212
213213BasicManager::BasicManager (Env* const env, const uint32 num_load_threads,
214214 const uint32 num_unload_threads,
215215 uint32 max_num_load_retries,
216216 int64 load_retry_interval_micros,
217- bool flush_filesystem_caches,
218217 std::unique_ptr<ResourceTracker> resource_tracker,
219218 EventBus<ServableState>* servable_event_bus,
220219 std::function<void (const ServableId&)> pre_load_hook)
221220 : servable_event_bus_(servable_event_bus),
222221 env_ (env),
223222 num_load_threads_(num_load_threads),
224- flush_filesystem_caches_(flush_filesystem_caches),
225223 pre_load_hook_(std::move(pre_load_hook)) {
226224 harness_options_.max_num_load_retries = max_num_load_retries;
227225 harness_options_.load_retry_interval_micros = load_retry_interval_micros;
@@ -231,7 +229,7 @@ BasicManager::BasicManager(Env* const env, const uint32 num_load_threads,
231229 };
232230
233231 {
234- mutex_lock l (load_executor_mu_ );
232+ mutex_lock l (num_load_threads_mu_ );
235233 load_executor_ =
236234 CreateExecutor (env_, num_load_threads, " BasicManager_Load_ThreadPool" );
237235 }
@@ -243,7 +241,7 @@ BasicManager::BasicManager(Env* const env, const uint32 num_load_threads,
243241BasicManager::~BasicManager () {
244242 // Reset the executors first to finish all pending loads/unloads.
245243 {
246- mutex_lock l (load_executor_mu_ );
244+ mutex_lock l (num_load_threads_mu_ );
247245 load_executor_.reset ();
248246 }
249247 unload_executor_.reset ();
@@ -464,18 +462,7 @@ Status BasicManager::ExecuteLoad(LoaderHarness* harness) {
464462 }
465463
466464 // We don't hold the lock while calling Load() as it may block.
467- const Status status = harness->Load ();
468-
469- // Whether the load succeeded or failed, flush filesystem caches if there is
470- // only one load thread.
471- if (flush_filesystem_caches_ && num_load_threads () <= 1 ) {
472- const Status flush_status = Env::Default ()->FlushFileSystemCaches ();
473- if (!flush_status.ok ()) {
474- LOG (WARNING) << " flushing filesystem caches failed: " << flush_status;
475- }
476- }
477-
478- TF_RETURN_IF_ERROR (status);
465+ TF_RETURN_IF_ERROR (harness->Load ());
479466
480467 {
481468 mutex_lock l (mu_);
@@ -559,16 +546,18 @@ Status BasicManager::ExecuteLoadOrUnload(const LoadOrUnloadRequest& request,
559546}
560547
561548void BasicManager::SetNumLoadThreads (const uint32 num_load_threads) {
562- mutex_lock l (load_executor_mu_ );
549+ mutex_lock l (num_load_threads_mu_ );
563550
564551 load_executor_.reset ();
565- num_load_threads_. store ( num_load_threads) ;
552+ num_load_threads_ = num_load_threads;
566553 load_executor_ =
567- CreateExecutor (env_, num_load_threads , " BasicManager_Load_ThreadPool" );
554+ CreateExecutor (env_, num_load_threads_ , " BasicManager_Load_ThreadPool" );
568555}
569556
570557uint32 BasicManager::num_load_threads () const {
571- return num_load_threads_.load ();
558+ mutex_lock l (num_load_threads_mu_);
559+
560+ return num_load_threads_;
572561}
573562
574563void BasicManager::LoadOrUnloadServable (const LoadOrUnloadRequest& request,
@@ -596,7 +585,7 @@ void BasicManager::LoadOrUnloadServable(const LoadOrUnloadRequest& request,
596585
597586 switch (request.kind ) {
598587 case LoadOrUnloadRequest::Kind::kLoad : {
599- mutex_lock l (load_executor_mu_ );
588+ mutex_lock l (num_load_threads_mu_ );
600589 load_executor_->Schedule ([this , request, done_callback]() {
601590 HandleLoadOrUnloadRequest (request, done_callback);
602591 });
0 commit comments