Research if data can append to a protobuf file
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.
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);
Assign to Nicky. Check if there are other appending example. This should resolve a huge part of https://github.com/PaddlePaddle/VisualDL/issues/284
close outdated issue.