Should we split Executor::Run into Executor::Prepare and Executor::exe
Created by: reyoung
Problem
We create new operators in CPP when Executor::Run
is invoked since we assume the topology may be changed every time. However, the program is usually not changed. To create operators locally or sending protobuf again and again to a remote node is very time-consuming.
Solution
To reduce the time cost of creating operators in local mode and network communication in cluster mode, we can extract a method named Executor::Prepare
.
class Executor {
public:
using HANDLE=int;
virtual HANDLE Prepare(program, feed_list, fetch_list) = 0;
virtual void Exec(HANDLE handle) = 0;
void Run(program, feed_list, fetch_list) {
Exec(Prepare(program, feed_list, fetch_list));
}
private:
vector<Ops> prepared_ops_;
};
Prepare return a HANDLE
.
In local mode, It could be an array index of an internal data structure of Executor. The internal data structure holds the C++ operators which the program contains.
In cluster mode, Prepare
could just send the protobuf of the program to a remote node. The handle could be an RPC return value. We can just send the HANDLE to remote to execute the associated program, instead of serializing and sending protobuf again and again.