MCPcopy Create free account
hub / github.com/dmlc/parameter_server / process

Method process

src/parameter/shared_parameter.h:98–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97template <typename K>
98void SharedParameter<K>::process(const MessagePtr& msg) {
99 bool req = msg->task.request();
100 int chl = msg->task.key_channel();
101 auto call = get(msg);
102 bool push = call.cmd() == CallSharedPara::PUSH;
103 bool pull = call.cmd() == CallSharedPara::PULL;
104 MessagePtr reply;
105 if (pull && req) {
106 reply = MessagePtr(new Message(*msg));
107 reply->task.set_request(false);
108 std::swap(reply->sender, reply->recver);
109 }
110
111 // this->sys_.hb().startTimer(HeartbeatInfo::TimerType::BUSY);
112 // process
113 if (call.replica()) {
114 if (pull && !req && Range<K>(msg->task.key_range()) == myKeyRange()) {
115 recoverFrom(msg);
116 } else if ((push && req) || (pull && !req)) {
117 setReplica(msg);
118 } else if (pull && req) {
119 getReplica(reply);
120 }
121 } else if (call.has_tail_filter()) {
122 if (key_filter_ignore_chl_) chl = 0;
123 auto cmd = call.tail_filter();
124 // push the key count
125 if (cmd.insert_count() && req && !msg->key.empty()) {
126 CHECK(!msg->value.empty());
127 auto& filter = key_filter_[chl];
128 if (filter.empty()) {
129 double w = (double)FLAGS_num_workers;
130 filter.resize(w*cmd.countmin_n()/log(w+1), cmd.countmin_k());
131 }
132 filter.insertKeys(SArray<K>(msg->key), SArray<uint8>(msg->value[0]));
133 }
134 // pull the filtered keys
135 if (cmd.has_query_key() && pull) {
136 if (req) {
137 reply->clearData();
138 reply->setKey(key_filter_[chl].queryKeys(
139 SArray<K>(msg->key), cmd.query_key()));
140 if (cmd.has_query_value()) {
141 getValue(reply);
142 }
143 } else {
144 setValue(msg);
145 }
146 }
147 } else {
148 if ((push && req) || (pull && !req)) {
149 setValue(msg);
150 } else if (pull && req) {
151 getValue(reply);
152 }
153 }
154 // this->sys_.hb().stopTimer(HeartbeatInfo::TimerType::BUSY);
155

Callers

nothing calls this directly

Calls 15

requestMethod · 0.80
key_channelMethod · 0.80
set_requestMethod · 0.80
replicaMethod · 0.80
has_tail_filterMethod · 0.80
insert_countMethod · 0.80
insertKeysMethod · 0.80
has_query_keyMethod · 0.80
clearDataMethod · 0.80
setKeyMethod · 0.80
queryKeysMethod · 0.80
query_keyMethod · 0.80

Tested by

no test coverage detected