aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/transactionlog/chunks_test.cpp
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-01-05 15:45:34 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-01-05 15:45:34 +0000
commit7deeb69934ecddba55bd7af9d7b5b87355dd6427 (patch)
treeedff2032104e8e68b137859b45018869c4ff5079 /searchlib/src/tests/transactionlog/chunks_test.cpp
parentfcce4873d66e5e5140fa470a22cbb3e752159ea2 (diff)
If TLS buffer has more than 8x overhead, shrink it to fit prior to posting task for compression.
Intention to reduce amount of allocated memory in flight in the case there are cpu starvation, or something else causing hickups.
Diffstat (limited to 'searchlib/src/tests/transactionlog/chunks_test.cpp')
-rw-r--r--searchlib/src/tests/transactionlog/chunks_test.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/searchlib/src/tests/transactionlog/chunks_test.cpp b/searchlib/src/tests/transactionlog/chunks_test.cpp
index 8d6620c9f8b..ca03a47634d 100644
--- a/searchlib/src/tests/transactionlog/chunks_test.cpp
+++ b/searchlib/src/tests/transactionlog/chunks_test.cpp
@@ -115,4 +115,25 @@ TEST("test multi element commitchunk") {
}
EXPECT_EQUAL(0u, counter);
}
+
+TEST("shrinkToFit if difference is larger than 8x") {
+ Packet p(16000);
+ p.add(Packet::Entry(1, 3, ConstBufferRef(TEXT, strlen(TEXT))));
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(16384u, p.getHandle().capacity());
+ p.shrinkToFit();
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(150u, p.getHandle().capacity());
+}
+
+TEST("not shrinkToFit if difference is less than 8x") {
+ Packet p(1000);
+ p.add(Packet::Entry(1, 3, ConstBufferRef(TEXT, strlen(TEXT))));
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(1024u, p.getHandle().capacity());
+ p.shrinkToFit();
+ EXPECT_EQUAL(150u, p.sizeBytes());
+ EXPECT_EQUAL(1024u, p.getHandle().capacity());
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }