mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-21 04:24:37 +02:00
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:
@@ -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_;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user