Unverified Commit e4ef8d1a authored by Chao Ma's avatar Chao Ma Committed by GitHub
Browse files

[KVStore] API change of kvstore (#1058)

* API change of kvstore

* add demo for kvstore

* update

* remove duplicated log

* change queue size

* update

* update

* update

* update

* update

* update

* update

* update

* update

* fix lint

* change name

* update

* fix lint

* update

* update

* update

* update

* change message queue size to a python argument
parent 41f8a162
...@@ -21,10 +21,6 @@ using dgl::runtime::NDArray; ...@@ -21,10 +21,6 @@ using dgl::runtime::NDArray;
namespace dgl { namespace dgl {
namespace network { namespace network {
// Max size of message queue for communicator is 200 MB
// TODO(chao): Make this number configurable
const int64_t kQueueSize = 200 * 1024 * 1024;
/*! /*!
* \brief Create NDArray from raw data * \brief Create NDArray from raw data
*/ */
...@@ -64,7 +60,11 @@ enum MessageType { ...@@ -64,7 +60,11 @@ enum MessageType {
/*! /*!
* \brief Barrier msg for KVStore * \brief Barrier msg for KVStore
*/ */
kBarrierMsg = 6 kBarrierMsg = 6,
/*!
* \brief IP and ID msg for KVStore
*/
kIPIDMsg = 7
}; };
/*! /*!
......
...@@ -33,7 +33,6 @@ STATUS MessageQueue::Add(Message msg, bool is_blocking) { ...@@ -33,7 +33,6 @@ STATUS MessageQueue::Add(Message msg, bool is_blocking) {
} }
std::unique_lock<std::mutex> lock(mutex_); std::unique_lock<std::mutex> lock(mutex_);
if (finished_producers_.size() >= num_producers_) { if (finished_producers_.size() >= num_producers_) {
LOG(WARNING) << "Message queue is closed.";
return QUEUE_CLOSE; return QUEUE_CLOSE;
} }
if (msg.size > free_size_ && !is_blocking) { if (msg.size > free_size_ && !is_blocking) {
...@@ -58,7 +57,6 @@ STATUS MessageQueue::Remove(Message* msg, bool is_blocking) { ...@@ -58,7 +57,6 @@ STATUS MessageQueue::Remove(Message* msg, bool is_blocking) {
return QUEUE_EMPTY; return QUEUE_EMPTY;
} }
if (finished_producers_.size() >= num_producers_) { if (finished_producers_.size() >= num_producers_) {
LOG(WARNING) << "Message queue is closed.";
return QUEUE_CLOSE; return QUEUE_CLOSE;
} }
} }
...@@ -67,7 +65,6 @@ STATUS MessageQueue::Remove(Message* msg, bool is_blocking) { ...@@ -67,7 +65,6 @@ STATUS MessageQueue::Remove(Message* msg, bool is_blocking) {
return !queue_.empty() || exit_flag_.load(); return !queue_.empty() || exit_flag_.load();
}); });
if (finished_producers_.size() >= num_producers_ && queue_.empty()) { if (finished_producers_.size() >= num_producers_ && queue_.empty()) {
LOG(WARNING) << "Message queue is closed.";
return QUEUE_CLOSE; return QUEUE_CLOSE;
} }
......
...@@ -65,7 +65,6 @@ bool SocketSender::Connect() { ...@@ -65,7 +65,6 @@ bool SocketSender::Connect() {
int port = r.second.port; int port = r.second.port;
while (bo == false && try_count < kMaxTryCount) { while (bo == false && try_count < kMaxTryCount) {
if (client_socket->Connect(ip, port)) { if (client_socket->Connect(ip, port)) {
LOG(INFO) << "Connected to Receiver: " << ip << ":" << port;
bo = true; bo = true;
} else { } else {
LOG(ERROR) << "Cannot connect to Receiver: " << ip << ":" << port LOG(ERROR) << "Cannot connect to Receiver: " << ip << ":" << port
...@@ -195,12 +194,10 @@ bool SocketReceiver::Wait(const char* addr, int num_sender) { ...@@ -195,12 +194,10 @@ bool SocketReceiver::Wait(const char* addr, int num_sender) {
if (server_socket_->Bind(ip.c_str(), port) == false) { if (server_socket_->Bind(ip.c_str(), port) == false) {
LOG(FATAL) << "Cannot bind to " << ip << ":" << port; LOG(FATAL) << "Cannot bind to " << ip << ":" << port;
} }
LOG(INFO) << "Bind to " << ip << ":" << port;
// Listen // Listen
if (server_socket_->Listen(kMaxConnection) == false) { if (server_socket_->Listen(kMaxConnection) == false) {
LOG(FATAL) << "Cannot listen on " << ip << ":" << port; LOG(FATAL) << "Cannot listen on " << ip << ":" << port;
} }
LOG(INFO) << "Listen on " << ip << ":" << port << ", wait sender connect ...";
// Accept all sender sockets // Accept all sender sockets
std::string accept_ip; std::string accept_ip;
int accept_port; int accept_port;
...@@ -215,7 +212,6 @@ bool SocketReceiver::Wait(const char* addr, int num_sender) { ...@@ -215,7 +212,6 @@ bool SocketReceiver::Wait(const char* addr, int num_sender) {
RecvLoop, RecvLoop,
sockets_[i].get(), sockets_[i].get(),
msg_queue_[i].get()); msg_queue_[i].get());
LOG(INFO) << "Accept new sender: " << accept_ip << ":" << accept_port;
} }
return true; return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment