Skip to content

Commit

Permalink
Merge pull request #506 from openzim/writer_buffer_size
Browse files Browse the repository at this point in the history
Use a bigger chunk size to write clusters.
  • Loading branch information
kelson42 committed Feb 23, 2021
2 parents 9ae6196 + c24312f commit 1ed3b93
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/writer/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
# define _write(fd, addr, size) ::write((fd), (addr), (size))
#endif

const zim::size_type MAX_WRITE_SIZE(4UL*1024*1024*1024-1);

namespace zim {
namespace writer {

Expand Down Expand Up @@ -194,7 +196,7 @@ void Cluster::write(int out_fd) const
size_type to_write = data.size();
const char* src = data.data();
while (to_write) {
size_type chunk_size = to_write > 4096 ? 4096 : to_write;
size_type chunk_size = std::min(MAX_WRITE_SIZE, to_write);
auto ret = _write(out_fd, src, chunk_size);
src += ret;
to_write -= ret;
Expand Down

0 comments on commit 1ed3b93

Please sign in to comment.