diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-01-05 17:55:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-05 17:55:50 +0100 |
commit | f240234d803a4848652d427c6303436fe7ca822b (patch) | |
tree | edff2032104e8e68b137859b45018869c4ff5079 /searchlib/src/vespa/searchlib/transactionlog/common.cpp | |
parent | fcce4873d66e5e5140fa470a22cbb3e752159ea2 (diff) | |
parent | 7deeb69934ecddba55bd7af9d7b5b87355dd6427 (diff) |
Merge pull request #20666 from vespa-engine/balder/shrink-buffer-to-fit-if-overhead-is-larger-than-8xv7.523.17
If TLS buffer has more than 8x overhead, shrink it to fit prior to po…
Diffstat (limited to 'searchlib/src/vespa/searchlib/transactionlog/common.cpp')
-rw-r--r-- | searchlib/src/vespa/searchlib/transactionlog/common.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.cpp b/searchlib/src/vespa/searchlib/transactionlog/common.cpp index 967f8748174..4130ad0bc06 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/common.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/common.cpp @@ -116,6 +116,14 @@ Packet::add(const Packet::Entry & e) _range.to(e.serial()); } +void +Packet::shrinkToFit() { + if (_buf.size() * 8 < _buf.capacity()) { + nbostream::Buffer shrunkToFit(_buf.data(), _buf.data() + _buf.size()); + _buf.swap(shrunkToFit); + } +} + Writer::CommitResult::CommitResult() : _callBacks() {} @@ -151,4 +159,9 @@ CommitChunk::createCommitResult() const { return Writer::CommitResult(_callBacks); } +void +CommitChunk::shrinkPayloadToFit() { + _data.shrinkToFit(); +} + } |