FS: Fix performance on high latency systems
fseek() in File::append() was invalidating the file buffer for each call
to append(). Better handling improves "import" performance test by 9%,
45% in "commit", on a system with a spinning disk.
This performance problem affects all operations where
{pending,completed}.data are rewritten. During normal operation a
garbage collection can be enough to trigger it. On storage with high
latency, e.g. networked, this previously took 20 seconds and more.
This commit is contained in:
14
src/FS.cpp
14
src/FS.cpp
@@ -505,7 +505,19 @@ void File::append (const std::vector <std::string>& lines)
|
||||
{
|
||||
fseek (_fh, 0, SEEK_END);
|
||||
for (auto& line : lines)
|
||||
fputs ((line + "\n").c_str (), _fh);
|
||||
fputs (line.c_str (), _fh);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void File::write_raw (const std::string& line)
|
||||
{
|
||||
if (!_fh)
|
||||
open ();
|
||||
|
||||
if (_fh)
|
||||
{
|
||||
fputs (line.c_str (), _fh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user