Skip to content

Commit 702c0cf

Browse files
committed
[flang] runtime perf: larger I/O buffer growth increments
When reallocating an I/O buffer to accommodate a large record, ensure that the amount of growth is at least as large as the minimum initial record size (64KiB). The previous policy was causing input buffer reallocation for each byte after the minimum buffer size when scanning input data for record termination newlines. Differential Revision: https://reviews.llvm.org/D118649
1 parent 623b66e commit 702c0cf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/runtime/buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
135135
if (bytes > size_) {
136136
char *old{buffer_};
137137
auto oldSize{size_};
138-
size_ = std::max<std::int64_t>(bytes, minBuffer);
138+
size_ = std::max<std::int64_t>(bytes, size_ + minBuffer);
139139
buffer_ =
140140
reinterpret_cast<char *>(AllocateMemoryOrCrash(terminator, size_));
141141
auto chunk{std::min<std::int64_t>(length_, oldSize - start_)};

0 commit comments

Comments
 (0)