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

Method GC

tensorflow/core/distributed_runtime/master.cc:91–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void Master::GC() {
92 Env* env = Env::Default();
93 while (true) {
94 mutex_lock l(mu_);
95 const int kTimeoutMilliseconds = 10 * 1000; // 10 seconds.
96 WaitForMilliseconds(&l, &shutdown_cv_, kTimeoutMilliseconds);
97 if (shutdown_) {
98 break;
99 }
100 std::vector<string> handles;
101 const int64 num_micros = static_cast<int64>(session_gc_seconds_ * 1000000);
102 for (const auto& entry : sessions_) {
103 int64 lat = entry.second->last_access_time_usec();
104 if (static_cast<int64>(env->NowMicros()) - lat > num_micros) {
105 handles.push_back(entry.first);
106 auto* sess = entry.second;
107 SchedClosure([this, sess]() {
108 LOG(WARNING) << "GC session " << sess->handle() << " after "
109 << session_gc_seconds_ << " seconds. "
110 << "Note that if you are starting multiple replicas "
111 << "on a staggered delay, session_gc_seconds may need "
112 << "to be raised.";
113 sess->GarbageCollect();
114 });
115 }
116 }
117 for (const auto& handle : handles) sessions_.erase(handle);
118 }
119}
120
121MasterSession* Master::FindMasterSession(const string& handle) {
122 MasterSession* session = nullptr;

Callers 1

forceGCFunction · 0.80

Calls 9

DefaultFunction · 0.85
WaitForMillisecondsFunction · 0.85
SchedClosureFunction · 0.85
last_access_time_usecMethod · 0.80
GarbageCollectMethod · 0.80
NowMicrosMethod · 0.45
push_backMethod · 0.45
handleMethod · 0.45
eraseMethod · 0.45

Tested by 1

forceGCFunction · 0.64