Set the file size in advance on GPFS

When started to use the buffer on GPFS we notices an increase
of metadata access times on GPFS. To try to reduce the number
of metadata updates we set the file size at creation time.
This commit is contained in:
babic_a committed 2020-07-17 12:09:46 +02:00
1 parent 83dc003c79
commit 2bf658d30c
2 files changed
+41

No files matched your search

+3
View File
@@ -7,6 +7,9 @@
class BufferBinaryWriter {
const size_t MAX_FILE_BYTES =
buffer_config::FILE_MOD * sizeof(BufferBinaryFormat);
const std::string root_folder_;
const std::string device_name_;
std::string latest_filename_;
+38
View File
@@ -98,6 +98,44 @@ void BufferBinaryWriter::open_file(const std::string& filename)
throw runtime_error(err_msg.str());
}
// TODO: Remove context if test successful.
/** Setting the buffer file size in advance to try to lower the number of
metadata updates on GPFS. */
{
if (lseek(output_file_fd_, MAX_FILE_BYTES, SEEK_SET) < 0) {
stringstream err_msg;
using namespace date;
using namespace chrono;
err_msg << "[" << system_clock::now() << "]";
err_msg << "[BufferBinaryWriter::open_file]";
err_msg << " Error while lseek on end of file ";
err_msg << current_output_filename_;
err_msg << " for MAX_FILE_BYTES ";
err_msg << MAX_FILE_BYTES << ": ";
err_msg << strerror(errno) << endl;
throw runtime_error(err_msg.str());
}
const uint8_t mark = 255;
if(::write(output_file_fd_, &mark, sizeof(mark)) != sizeof(mark)) {
stringstream err_msg;
using namespace date;
using namespace chrono;
err_msg << "[" << system_clock::now() << "]";
err_msg << "[BufferBinaryWriter::open_file]";
err_msg << " Error while writing to file ";
err_msg << current_output_filename_ << ": ";
err_msg << strerror(errno) << endl;
throw runtime_error(err_msg.str());
}
}
current_output_filename_ = filename;
}