VisualDL icon indicating copy to clipboard operation
VisualDL copied to clipboard

Research if data can append to a protobuf file

Open jetfuel opened this issue 8 years ago • 3 comments

At the moment, each PersistToDisk function call will trigger proto.SerializeToOstream(&file); and its a very expansive operation. The system is rewriting the whole data to the filesystem. This is inefficient and the operation will get more expansive as the data grows.

We should research if Protobuf allows us to append data into an existing file. That should allow VisualDL to work with training that takes huge data points.

jetfuel avatar Mar 15 '18 18:03 jetfuel

The C++ Protobuf can use SerializeDelimitedToOstream and SerializeDelimitedToCodedStream to append data.

Here is the PR that provides the functionality. https://github.com/google/protobuf/pull/710/files There are some restrictions. We must maintain the same ostream to write the data. Same practice when reading.

Here is the code snippet.

#include <google/protobuf/util/delimited_message_util.h>
...
static std::ofstream file("./temp_file", std::ios::binary);
google::protobuf::util::SerializeDelimitedToOstream(proto, &file);

jetfuel avatar Mar 16 '18 22:03 jetfuel

Assign to Nicky. Check if there are other appending example. This should resolve a huge part of https://github.com/PaddlePaddle/VisualDL/issues/284

jetfuel avatar Apr 17 '18 23:04 jetfuel

close outdated issue.

PeterPanZH avatar Jun 28 '20 06:06 PeterPanZH