diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-02-15 13:54:49 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-02-15 14:16:21 +0000 |
commit | 805a313df05d2f347af321511527e06ea3cae92c (patch) | |
tree | 7e06fbd1c2d5ababf3d219ddb6c4b0cf9525aea9 | |
parent | c0b8734987176a93588909739af143c6b0a1a6ff (diff) |
use size literals in searchlib
58 files changed, 194 insertions, 136 deletions
diff --git a/searchlib/src/apps/docstore/benchmarkdatastore.cpp b/searchlib/src/apps/docstore/benchmarkdatastore.cpp index 4c0ac937bfd..20f06a087f5 100644 --- a/searchlib/src/apps/docstore/benchmarkdatastore.cpp +++ b/searchlib/src/apps/docstore/benchmarkdatastore.cpp @@ -2,10 +2,11 @@ #include <vespa/searchlib/docstore/logdatastore.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> -#include <vespa/vespalib/util/lambdatask.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> -#include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/data/databuffer.h> +#include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/size_literals.h> +#include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/fastos/app.h> #include <unistd.h> #include <random> @@ -95,12 +96,12 @@ BenchmarkDataStoreApp::benchmark(const vespalib::string & dir, size_t numReads, tuning._randRead.setWantMemoryMap(); } search::index::DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); transactionlog::NoSyncProxy noTlSyncer; LogDataStore store(executor, dir, config, growStrategy, tuning, fileHeaderContext, noTlSyncer, NULL, true); - vespalib::ThreadStackExecutor bmPool(numThreads, 128*1024); + vespalib::ThreadStackExecutor bmPool(numThreads, 128_Ki); LOG(info, "Start read benchmark with %lu threads doing %lu reads in chunks of %lu reads. Totally %lu objects", numThreads, numReads, perChunk, numThreads * numReads * perChunk); for (size_t i(0); i < numThreads; i++) { bmPool.execute(vespalib::makeLambdaTask([&]() { read(numReads, perChunk, static_cast<const IDataStore *>(&store)); })); diff --git a/searchlib/src/apps/docstore/documentstoreinspect.cpp b/searchlib/src/apps/docstore/documentstoreinspect.cpp index 8a3bb6b247b..8acc2312d46 100644 --- a/searchlib/src/apps/docstore/documentstoreinspect.cpp +++ b/searchlib/src/apps/docstore/documentstoreinspect.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/transactionlog/nosyncproxy.h> #include <vespa/fastos/app.h> #include <vespa/vespalib/objects/nbostream.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <cinttypes> @@ -106,7 +107,7 @@ DocumentStoreInspectApp::verify(const vespalib::string & dir) GrowStrategy growStrategy; TuneFileSummary tuning; search::index::DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); transactionlog::NoSyncProxy noTlSyncer; LogDataStore store(executor, dir, config, growStrategy, tuning, diff --git a/searchlib/src/apps/docstore/verifylogdatastore.cpp b/searchlib/src/apps/docstore/verifylogdatastore.cpp index 498516882c1..c148f12f9ee 100644 --- a/searchlib/src/apps/docstore/verifylogdatastore.cpp +++ b/searchlib/src/apps/docstore/verifylogdatastore.cpp @@ -6,6 +6,7 @@ #include <vespa/searchlib/transactionlog/nosyncproxy.h> #include <vespa/fastos/app.h> #include <vespa/vespalib/util/exception.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> using namespace search; @@ -49,7 +50,7 @@ VerifyLogDataStoreApp::verify(const vespalib::string & dir) GrowStrategy growStrategy; TuneFileSummary tuning; search::index::DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); transactionlog::NoSyncProxy noTlSyncer; try { diff --git a/searchlib/src/apps/tests/biglogtest.cpp b/searchlib/src/apps/tests/biglogtest.cpp index 788fb855c7f..efe6585ae69 100644 --- a/searchlib/src/apps/tests/biglogtest.cpp +++ b/searchlib/src/apps/tests/biglogtest.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/transactionlog/nosyncproxy.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/data/databuffer.h> @@ -134,7 +135,7 @@ factory<LogDataStore>::factory(std::string dir) : DioTune(), _fileHeaderContext(), _config(), - _executor(1, 128*1024), + _executor(1, 128_Ki), _noTlSyncer(), _datastore(_executor, dir, _config, GrowStrategy(), tuning, _fileHeaderContext, _noTlSyncer, NULL) {} diff --git a/searchlib/src/apps/tests/btreestress_test.cpp b/searchlib/src/apps/tests/btreestress_test.cpp index 37fc6b26cc3..b41f663f5f7 100644 --- a/searchlib/src/apps/tests/btreestress_test.cpp +++ b/searchlib/src/apps/tests/btreestress_test.cpp @@ -1,12 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/vespalib/btree/btreeroot.h> +#include <vespa/vespalib/btree/btree.h> #include <vespa/vespalib/btree/btreebuilder.h> #include <vespa/vespalib/btree/btreenodeallocator.h> -#include <vespa/vespalib/btree/btree.h> +#include <vespa/vespalib/btree/btreeroot.h> #include <vespa/vespalib/btree/btreestore.h> + +#include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/rand48.h> +#include <vespa/vespalib/util/size_literals.h> +#include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/btree/btreenodeallocator.hpp> #include <vespa/vespalib/btree/btreenode.hpp> @@ -18,9 +22,6 @@ #include <vespa/vespalib/btree/btreestore.hpp> #include <vespa/vespalib/btree/btreeaggregator.hpp> -#include <vespa/vespalib/util/threadstackexecutor.h> -#include <vespa/vespalib/util/lambdatask.h> - #include <vespa/log/log.h> LOG_SETUP("btreestress_test"); @@ -62,8 +63,8 @@ Fixture::Fixture() : _generationHandler(), _tree(), _writeItr(_tree.begin()), - _writer(1, 128 * 1024), - _readers(4, 128 * 1024), + _writer(1, 128_Ki), + _readers(4, 128_Ki), _rnd(), _keyLimit(1000000), _readSeed(50), diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index e8590999bc1..b013f6a9d27 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -24,6 +24,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP("memoryindexstress_test"); @@ -248,13 +249,13 @@ VESPA_THREAD_STACK_TAG(push_executor) Fixture::Fixture(uint32_t readThreads) : schema(makeSchema()), repo(makeDocTypeRepoConfig()), - _executor(1, 128 * 1024), + _executor(1, 128_Ki), _invertThreads(vespalib::SequencedTaskExecutor::create(invert_executor, 2)), _pushThreads(vespalib::SequencedTaskExecutor::create(push_executor, 2)), index(schema, MockFieldLengthInspector(), *_invertThreads, *_pushThreads), _readThreads(readThreads), - _writer(1, 128 * 1024), - _readers(readThreads, 128 * 1024), + _writer(1, 128_Ki), + _readers(readThreads, 128_Ki), _rnd(), _keyLimit(1000000), _readSeed(50), diff --git a/searchlib/src/tests/alignment/alignment.cpp b/searchlib/src/tests/alignment/alignment.cpp index bc903cabde5..62d19839b41 100644 --- a/searchlib/src/tests/alignment/alignment.cpp +++ b/searchlib/src/tests/alignment/alignment.cpp @@ -5,6 +5,7 @@ LOG_SETUP("alignment_test"); #include <sys/resource.h> #include <sys/time.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/size_literals.h> struct Timer { rusage usage; @@ -30,7 +31,7 @@ timeAccess(void *bufp, uint32_t len, double &sum) double *buf = (double *)bufp; Timer timer; timer.start(); - for(uint32_t i = 0; i < 512 * 1024; ++i) { + for(uint32_t i = 0; i < 512_Ki; ++i) { for (uint32_t j = 0; j < len; ++j) { sum += buf[j]; } diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index e65684d0ea5..079195a3a9a 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -20,6 +20,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/util/bufferwriter.h> #include <vespa/vespalib/util/compress.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/databuffer.h> #include <limits> @@ -58,7 +59,7 @@ public: } virtual Buffer allocBuf(size_t size) override { - return std::make_unique<BufferBuf>(size, 4096); + return std::make_unique<BufferBuf>(size, 4_Ki); } virtual void writeBuf(Buffer buf_in) override { diff --git a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp index c622ccae679..c41c8524a37 100644 --- a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp +++ b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp @@ -3,11 +3,12 @@ #include <vespa/searchlib/attribute/multi_value_mapping.h> #include <vespa/searchlib/attribute/multi_value_mapping.hpp> #include <vespa/searchlib/attribute/not_implemented_attribute.h> -#include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/util/generationhandler.h> +#include <vespa/vespalib/util/rand48.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP("multivaluemapping_test"); @@ -82,7 +83,7 @@ public: } void setup(uint32_t maxSmallArraySize, bool enable_free_lists = true) { ArrayStoreConfig config(maxSmallArraySize, - ArrayStoreConfig::AllocSpec(0, RefType::offsetSize(), 8 * 1024, ALLOC_GROW_FACTOR)); + ArrayStoreConfig::AllocSpec(0, RefType::offsetSize(), 8_Ki, ALLOC_GROW_FACTOR)); config.enable_free_lists(enable_free_lists); _mvMapping = std::make_unique<MvMapping>(config); _attr = std::make_unique<AttributeType>(*_mvMapping); diff --git a/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp b/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp index 5976b02c5cf..e2ae0a387ed 100644 --- a/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp +++ b/searchlib/src/tests/attribute/posting_list_merger/posting_list_merger_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/attribute/posting_list_merger.h> #include <vespa/vespalib/test/insertion_operators.h> +#include <vespa/vespalib/util/size_literals.h> #include <algorithm> using vespalib::btree::BTreeNoLeafData; @@ -56,7 +57,7 @@ public: } }; -constexpr uint32_t docIdLimit = 16384; +constexpr uint32_t docIdLimit = 16_Ki; struct WeightedFixture { diff --git a/searchlib/src/tests/attribute/sourceselector/sourceselector_test.cpp b/searchlib/src/tests/attribute/sourceselector/sourceselector_test.cpp index 54fb7ffd387..03584b0dde9 100644 --- a/searchlib/src/tests/attribute/sourceselector/sourceselector_test.cpp +++ b/searchlib/src/tests/attribute/sourceselector/sourceselector_test.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchcommon/common/undefinedvalues.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fastos/file.h> #include <vespa/log/log.h> @@ -20,7 +21,7 @@ using search::index::DummyFileHeaderContext; namespace { template <typename T, size_t N> size_t arraysize(const T (&)[N]) { return N; } -const uint32_t maxDocId = 4096; +const uint32_t maxDocId = 4_Ki; struct DocSource { uint32_t docId; uint8_t source; }; const DocSource docs[] = { {0,1}, {1, 0}, {2, 2}, {4, 3}, {8, 9}, {16, 178}, {32, 1}, {64, 2}, {128, 3}, {256,4}, {512, 2}, diff --git a/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp b/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp index ce36bc3503a..fd3c677f328 100644 --- a/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp +++ b/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp @@ -2,6 +2,7 @@ #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/size_literals.h> #include <vector> #include <algorithm> @@ -498,7 +499,7 @@ TestFixture<bigEndian>::testBoundaries(int kValue, bool small, std::vector<uint6 { EC e; search::ComprFileWriteContext wc(e); - wc.allocComprBuf(32768, 32768); + wc.allocComprBuf(32_Ki, 32_Ki); e.setupWrite(wc); for (auto num : v) { e.encodeExpGolomb(num, kValue); @@ -554,7 +555,7 @@ TestFixture<bigEndian>::testRandNums(int kValue) { EC e; search::ComprFileWriteContext wc(e); - wc.allocComprBuf(32768, 32768); + wc.allocComprBuf(32_Ki, 32_Ki); e.setupWrite(wc); for (auto num : _randNums) { e.encodeExpGolomb(num, kValue); diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index 15a53497db9..8755af9a133 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -1,21 +1,22 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/common/bitvector.h> -#include <vespa/vespalib/util/rand48.h> -#include <vespa/searchlib/test/fakedata/fakeword.h> -#include <vespa/searchlib/test/fakedata/fakewordset.h> +#include <vespa/searchlib/diskindex/fieldreader.h> +#include <vespa/searchlib/diskindex/fieldwriter.h> +#include <vespa/searchlib/diskindex/pagedict4file.h> +#include <vespa/searchlib/diskindex/pagedict4randread.h> +#include <vespa/searchlib/diskindex/zcposoccrandread.h> #include <vespa/searchlib/index/docidandfeatures.h> +#include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/index/field_length_info.h> #include <vespa/searchlib/index/postinglisthandle.h> -#include <vespa/searchlib/diskindex/zcposoccrandread.h> -#include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/index/schemautil.h> -#include <vespa/searchlib/diskindex/fieldwriter.h> -#include <vespa/searchlib/diskindex/fieldreader.h> +#include <vespa/searchlib/test/fakedata/fakeword.h> +#include <vespa/searchlib/test/fakedata/fakewordset.h> #include <vespa/vespalib/io/fileutil.h> -#include <vespa/searchlib/diskindex/pagedict4file.h> -#include <vespa/searchlib/diskindex/pagedict4randread.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/rand48.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/time.h> #include <openssl/sha.h> #include <vespa/fastos/app.h> @@ -55,7 +56,7 @@ void FastS_block_usr2() { } namespace fieldwriter { uint32_t minSkipDocs = 64; -uint32_t minChunkDocs = 262144; +uint32_t minChunkDocs = 256_Ki; vespalib::string dirprefix = "index/"; @@ -296,7 +297,7 @@ FileChecksum::FileChecksum(const vespalib::string &file_name) { SHA256_CTX c; FastOS_File f; - Alloc buf = Alloc::alloc(65536); + Alloc buf = Alloc::alloc(64_Ki); vespalib::string full_file_name(dirprefix + file_name); bool openres = f.OpenReadOnly(full_file_name.c_str()); if (!openres) { @@ -706,7 +707,7 @@ main(int argc, char **argv) { fieldwriter::FieldWriterTest app; - setvbuf(stdout, nullptr, _IOLBF, 32768); + setvbuf(stdout, nullptr, _IOLBF, 32_Ki); app._rnd.srand48(32); return app.Entry(argc, argv); } diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4_hugeword_cornercase_test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4_hugeword_cornercase_test.cpp index 8fb0e48663c..dd0bb9c8c40 100644 --- a/searchlib/src/tests/diskindex/pagedict4/pagedict4_hugeword_cornercase_test.cpp +++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4_hugeword_cornercase_test.cpp @@ -1,6 +1,7 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/countcompression.h> #include <vespa/searchlib/bitcompression/pagedict4.h> @@ -15,8 +16,8 @@ LOG_SETUP("pagedict4_hugeword_cornercase_test"); using search::index::PostingListCounts; using search::ComprFileWriteContext; -constexpr uint32_t minChunkDocs = 262144; -constexpr uint32_t numWordIds = 65536; +constexpr uint32_t minChunkDocs = 256_Ki; +constexpr uint32_t numWordIds = 64_Ki; struct BitBuffer { @@ -141,7 +142,7 @@ using SeqReader = search::diskindex::test::PageDict4MemSeqReader; */ void testPageSizedCounts() { - uint32_t pageBitSize = 32768; + uint32_t pageBitSize = 32_Ki; uint32_t startBits = 15 * 3 + 12; uint32_t ssPad = 64; diff --git a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp index cc31fcec4d4..22eae75b23b 100644 --- a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp +++ b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp @@ -12,6 +12,7 @@ #include <vespa/document/fieldvalue/document.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/log/log.h> @@ -236,8 +237,8 @@ Fixture::Fixture() _repo(makeDocTypeRepoConfig()), _storeConfig(DocumentStore::Config(CompressionConfig::NONE, 0, 0), LogDataStore::Config().setMaxFileSize(50000).setMaxBucketSpread(3.0) - .setFileConfig(WriteableFileChunk::Config(CompressionConfig(), 16384))), - _executor(1, 128 * 1024), + .setFileConfig(WriteableFileChunk::Config(CompressionConfig(), 16_Ki))), + _executor(1, 128_Ki), _fileHeaderContext(), _tlSyncer(), _store(), diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index 9e8203f352e..174feb14fdf 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -15,6 +15,7 @@ #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <vespa/vespalib/util/size_literals.h> #include <iomanip> using document::BucketId; @@ -134,33 +135,33 @@ checkStats(IDataStore &store, #ifdef __linux__ TEST("test that DirectIOPadding works accordng to spec") { - constexpr ssize_t FILE_SIZE = 4096*3; + constexpr ssize_t FILE_SIZE = 4_Ki*3; FastOS_File file("directio.test"); file.EnableDirectIO(); EXPECT_TRUE(file.OpenReadWrite()); - Alloc buf(Alloc::alloc_aligned(FILE_SIZE, 4096)); + Alloc buf(Alloc::alloc_aligned(FILE_SIZE, 4_Ki)); memset(buf.get(), 'a', buf.size()); EXPECT_EQUAL(FILE_SIZE, file.Write2(buf.get(), FILE_SIZE)); size_t padBefore(0); size_t padAfter(0); - EXPECT_TRUE(file.DirectIOPadding(4096, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4_Ki, 4096, padBefore, padAfter)); EXPECT_EQUAL(0u, padBefore); EXPECT_EQUAL(0u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(4095, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4095, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(4095u, padBefore); EXPECT_EQUAL(1u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(4097, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4097, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(1u, padBefore); EXPECT_EQUAL(4095u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(4096, 4097, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4_Ki, 4097, padBefore, padAfter)); EXPECT_EQUAL(0u, padBefore); EXPECT_EQUAL(4095u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(4096, 4095, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4_Ki, 4095, padBefore, padAfter)); EXPECT_EQUAL(0u, padBefore); EXPECT_EQUAL(1u, padAfter); @@ -168,15 +169,15 @@ TEST("test that DirectIOPadding works accordng to spec") { EXPECT_EQUAL(1u, padBefore); EXPECT_EQUAL(0u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(4097, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4097, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(1u, padBefore); EXPECT_EQUAL(4095u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(4097, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4097, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(1u, padBefore); EXPECT_EQUAL(4095u, padAfter); - EXPECT_FALSE(file.DirectIOPadding(FILE_SIZE-1, 4096, padBefore, padAfter)); + EXPECT_FALSE(file.DirectIOPadding(FILE_SIZE-1, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(0u, padBefore); EXPECT_EQUAL(0u, padAfter); EXPECT_EQUAL(FILE_SIZE, file.GetSize()); @@ -190,11 +191,11 @@ TEST("test that DirectIOPadding works accordng to spec") { EXPECT_EQUAL(FILE_SIZE*2, file2.GetSize()); EXPECT_TRUE(file2.Close()); - EXPECT_TRUE(file.DirectIOPadding(4097, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(4097, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(1u, padBefore); EXPECT_EQUAL(4095u, padAfter); - EXPECT_TRUE(file.DirectIOPadding(FILE_SIZE-1, 4096, padBefore, padAfter)); + EXPECT_TRUE(file.DirectIOPadding(FILE_SIZE-1, 4_Ki, padBefore, padAfter)); EXPECT_EQUAL(4095u, padBefore); EXPECT_EQUAL(1u, padAfter); @@ -205,7 +206,7 @@ TEST("test that DirectIOPadding works accordng to spec") { void verifyGrowing(const LogDataStore::Config & config, uint32_t minFiles, uint32_t maxFiles) { DirectoryHandler tmpDir("growing"); - vespalib::ThreadStackExecutor executor(4, 128*1024); + vespalib::ThreadStackExecutor executor(4, 128_Ki); DummyFileHeaderContext fileHeaderContext; MyTlSyncer tlSyncer; { @@ -276,7 +277,7 @@ void fetchAndTest(IDataStore & datastore, uint32_t lid, const void *a, size_t sz TEST("testTruncatedIdxFile"){ LogDataStore::Config config; DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); MyTlSyncer tlSyncer; { // Files comes from the 'growing test'. @@ -305,7 +306,7 @@ TEST("testTruncatedIdxFile"){ TEST("testThatEmptyIdxFilesAndDanglingDatFilesAreRemoved") { LogDataStore::Config config; DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); MyTlSyncer tlSyncer; LogDataStore datastore(executor, "dangling-test", config, GrowStrategy(), TuneFileSummary(), @@ -318,7 +319,7 @@ TEST("testThatEmptyIdxFilesAndDanglingDatFilesAreRemoved") { TEST("testThatIncompleteCompactedFilesAreRemoved") { LogDataStore::Config config; DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); MyTlSyncer tlSyncer; LogDataStore datastore(executor, "incompletecompact-test", config, GrowStrategy(), TuneFileSummary(), @@ -338,7 +339,7 @@ public: _myDir("visitcache"), _config(), _fileHeaderContext(), - _executor(1, 128*1024), + _executor(1, 128_Ki), _tlSyncer(), _datastore(_executor, _myDir.getDir(), _config, GrowStrategy(), TuneFileSummary(), _fileHeaderContext, _tlSyncer, nullptr) @@ -525,9 +526,9 @@ VisitCacheStore::VisitCacheStore(UpdateStrategy strategy) : _config(DocumentStore::Config(CompressionConfig::LZ4, 1000000, 0) .allowVisitCaching(true).updateStrategy(strategy), LogDataStore::Config().setMaxFileSize(50000).setMaxBucketSpread(3.0) - .setFileConfig(WriteableFileChunk::Config(CompressionConfig(), 16384))), + .setFileConfig(WriteableFileChunk::Config(CompressionConfig(), 16_Ki))), _fileHeaderContext(), - _executor(1, 128*1024), + _executor(1, 128_Ki), _tlSyncer(), _datastore(std::make_unique<LogDocumentStore>(_executor, _myDir.getDir(), _config, GrowStrategy(), TuneFileSummary(), _fileHeaderContext, _tlSyncer, nullptr)), @@ -669,7 +670,7 @@ TEST("testWriteRead") { { EXPECT_TRUE(FastOS_File::MakeDirectory("empty")); DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); MyTlSyncer tlSyncer; LogDataStore datastore(executor, "empty", config, GrowStrategy(), TuneFileSummary(), fileHeaderContext, tlSyncer, nullptr); @@ -705,7 +706,7 @@ TEST("testWriteRead") { } { DummyFileHeaderContext fileHeaderContext; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); MyTlSyncer tlSyncer; LogDataStore datastore(executor, "empty", config, GrowStrategy(), TuneFileSummary(), @@ -756,7 +757,7 @@ TEST("requireThatFlushTimeIsAvailableAfterFlush") { vespalib::system_time before(vespalib::system_clock::now()); DummyFileHeaderContext fileHeaderContext; LogDataStore::Config config; - vespalib::ThreadStackExecutor executor(1, 128*1024); + vespalib::ThreadStackExecutor executor(1, 128_Ki); MyTlSyncer tlSyncer; LogDataStore store(executor, testDir.getDir(), config, GrowStrategy(), TuneFileSummary(), fileHeaderContext, tlSyncer, nullptr); @@ -842,7 +843,7 @@ struct Fixture { Fixture(const vespalib::string &dirName = "tmp", bool dirCleanup = true, - size_t maxFileSize = 4096 * 2) + size_t maxFileSize = 4_Ki * 2) : executor(1, 0x20000), dir(dirName), serialNum(0), diff --git a/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp b/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp index e9514c1d385..1fcb5ffcf5b 100644 --- a/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp +++ b/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/docstore/storebybucket.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/stllike/hash_set.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/log/log.h> @@ -66,7 +67,7 @@ private: TEST("require that StoreByBucket gives bucket by bucket and ordered within") { vespalib::MemoryDataStore backing; - vespalib::ThreadStackExecutor executor(8, 128*1024); + vespalib::ThreadStackExecutor executor(8, 128_Ki); StoreByBucket sbb(backing, executor, CompressionConfig::LZ4); for (size_t i(1); i <=500; i++) { add(sbb, i); diff --git a/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp b/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp index ff91a27623d..47405f11028 100644 --- a/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp +++ b/searchlib/src/tests/fef/featurenameparser/featurenameparser_test.cpp @@ -3,6 +3,7 @@ LOG_SETUP("featurenameparser_test"); #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/searchlib/fef/featurenameparser.h> #include <vector> #include <string> @@ -61,7 +62,7 @@ Test::testParse(const vespalib::string &input, bool valid, void Test::testFile(const vespalib::string &name) { - char buf[4096]; + char buf[4_Ki]; uint32_t lineN = 0; FILE *f = fopen(name.c_str(), "r"); ASSERT_TRUE(f != 0); diff --git a/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp b/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp index 6bbaf16380d..8dbca39b692 100644 --- a/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp +++ b/searchlib/src/tests/memoryindex/memory_index/memory_index_test.cpp @@ -13,9 +13,10 @@ #include <vespa/searchlib/queryeval/fake_search.h> #include <vespa/searchlib/queryeval/fake_searchable.h> #include <vespa/searchlib/queryeval/searchiterator.h> +#include <vespa/vespalib/util/sequencedtaskexecutor.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/threadstackexecutor.h> -#include <vespa/vespalib/util/sequencedtaskexecutor.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/log/log.h> @@ -126,7 +127,7 @@ VESPA_THREAD_STACK_TAG(push_executor) Index::Index(const MySetup &setup) : schema(setup.schema), - _executor(1, 128 * 1024), + _executor(1, 128_Ki), _invertThreads(SequencedTaskExecutor::create(invert_executor, 2)), _pushThreads(SequencedTaskExecutor::create(push_executor, 2)), index(schema, setup, *_invertThreads, *_pushThreads), diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp index 0ac3f15e015..695710873c4 100644 --- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp +++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp @@ -11,6 +11,7 @@ #include <vespa/searchlib/test/fakedata/fakewordset.h> #include <vespa/searchlib/test/fakedata/fpfactory.h> #include <vespa/vespalib/util/rand48.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> @@ -232,7 +233,7 @@ main(int argc, char **argv) { postinglistbm::PostingListBM app; - setvbuf(stdout, nullptr, _IOLBF, 32768); + setvbuf(stdout, nullptr, _IOLBF, 32_Ki); app._rnd.srand48(32); return app.Entry(argc, argv); } diff --git a/searchlib/src/tests/postinglistbm/stress_runner.cpp b/searchlib/src/tests/postinglistbm/stress_runner.cpp index fd12e9b5aa9..b3ae7664614 100644 --- a/searchlib/src/tests/postinglistbm/stress_runner.cpp +++ b/searchlib/src/tests/postinglistbm/stress_runner.cpp @@ -8,6 +8,7 @@ #include <vespa/searchlib/test/fakedata/fakeword.h> #include <vespa/searchlib/test/fakedata/fakewordset.h> #include <vespa/searchlib/test/fakedata/fpfactory.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/time.h> #include <condition_variable> #include <mutex> @@ -159,7 +160,7 @@ StressMaster::StressMaster(vespalib::Rand48 &rnd, { LOG(info, "StressMaster::StressMaster()"); - _threadPool = new FastOS_ThreadPool(128 * 1024, 400); + _threadPool = new FastOS_ThreadPool(128_Ki, 400); } StressMaster::~StressMaster() diff --git a/searchlib/src/tests/query/streaming_query_large_test.cpp b/searchlib/src/tests/query/streaming_query_large_test.cpp index 28401e9d685..5eaa3cf0422 100644 --- a/searchlib/src/tests/query/streaming_query_large_test.cpp +++ b/searchlib/src/tests/query/streaming_query_large_test.cpp @@ -4,6 +4,7 @@ #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/query/tree/stackdumpcreator.h> #include <vespa/vespalib/testkit/test_kit.h> +#include <vespa/vespalib/util/size_literals.h> #include <sys/resource.h> using namespace search; @@ -36,9 +37,9 @@ void setMaxStackSize(rlim_t maxStackSize) TEST("testveryLongQueryResultingInBug6850778") { const uint32_t NUMITEMS=20000; #ifdef __SANITIZE_ADDRESS__ - setMaxStackSize(12 * 1024 * 1024); + setMaxStackSize(12_Mi); #else - setMaxStackSize(4 * 1024 * 1024); + setMaxStackSize(4_Mi); #endif QueryBuilder<SimpleQueryNodeTypes> builder; for (uint32_t i=0; i <= NUMITEMS; i++) { diff --git a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp index 8790df5a140..8e3bb95a776 100644 --- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp @@ -22,6 +22,7 @@ #include <vespa/vespalib/util/blockingthreadstackexecutor.h> #include <vespa/vespalib/util/generationhandler.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/simple_buffer.h> #include <vespa/log/log.h> @@ -59,7 +60,7 @@ struct MallocPointVector { }; static MallocPointVector *aligned_alloc_pv(size_t num) { size_t num_bytes = num * sizeof(MallocPointVector); - double mega_bytes = num_bytes / (1024.0*1024.0); + double mega_bytes = num_bytes / double(1_Mi); fprintf(stderr, "allocate %.2f MB of vectors\n", mega_bytes); char *mem = (char *)malloc(num_bytes + 512); mem += 512; @@ -221,8 +222,8 @@ public: vectors(), gen_handler(), index(), - multi_prepare_workers(10, 128*1024, 50), - write_thread(1, 128*1024, 500) + multi_prepare_workers(10, 128_Ki, 50), + write_thread(1, 128_Ki, 500) { loaded_vectors.load(); } diff --git a/searchlib/src/tests/util/slime_output_raw_buf_adapter/slime_output_raw_buf_adapter_test.cpp b/searchlib/src/tests/util/slime_output_raw_buf_adapter/slime_output_raw_buf_adapter_test.cpp index bb597537663..c8231ac4b29 100644 --- a/searchlib/src/tests/util/slime_output_raw_buf_adapter/slime_output_raw_buf_adapter_test.cpp +++ b/searchlib/src/tests/util/slime_output_raw_buf_adapter/slime_output_raw_buf_adapter_test.cpp @@ -2,12 +2,13 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/util/slime_output_raw_buf_adapter.h> #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/vespalib/util/size_literals.h> using namespace search; using namespace vespalib::slime::convenience; TEST("use slime with rawbuf") { - RawBuf buffer(4096); + RawBuf buffer(4_Ki); Slime src; Slime dst; { diff --git a/searchlib/src/tests/vespa-fileheader-inspect/vespa-fileheader-inspect_test.cpp b/searchlib/src/tests/vespa-fileheader-inspect/vespa-fileheader-inspect_test.cpp index 5a3f1a685ad..f9306bc5fbf 100644 --- a/searchlib/src/tests/vespa-fileheader-inspect/vespa-fileheader-inspect_test.cpp +++ b/searchlib/src/tests/vespa-fileheader-inspect/vespa-fileheader-inspect_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/searchlib/util/fileheadertk.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fastos/file.h> using namespace search; @@ -24,7 +25,7 @@ vespalib::string readFile(const vespalib::string &fileName) { FastOS_File file; ASSERT_TRUE(file.OpenReadOnly(fileName.c_str())); - char buf[4096]; + char buf[4_Ki]; uint32_t len = file.Read(buf, sizeof(buf)); EXPECT_LESS(len, sizeof(buf)); // make sure we got everything diff --git a/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp b/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp index 829720e9c3e..13300fb47f2 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/vespalib/data/databuffer.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fastos/file.h> #include <vespa/log/log.h> @@ -19,15 +20,15 @@ namespace search { namespace { -const uint32_t headerAlign = 4096; -const uint32_t MIN_ALIGNMENT = 4096; +const uint32_t headerAlign = 4_Ki; +const uint32_t MIN_ALIGNMENT = 4_Ki; void writeDirectIOAligned(FastOS_FileInterface &file, const void *buf, size_t length) { const char * data(static_cast<const char *>(buf)); size_t remaining(length); - for (size_t maxChunk(2048*1024); maxChunk >= MIN_ALIGNMENT; maxChunk >>= 1) { + for (size_t maxChunk(2_Mi); maxChunk >= MIN_ALIGNMENT; maxChunk >>= 1) { for ( ; remaining > maxChunk; remaining -= maxChunk, data += maxChunk) { file.WriteBuf(data, maxChunk); } diff --git a/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp b/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp index 8d412364815..7662df9443e 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp @@ -3,12 +3,13 @@ #include "attributememoryfilewriter.h" #include "attributememoryfilebufferwriter.h" #include <vespa/vespalib/data/databuffer.h> +#include <vespa/vespalib/util/size_literals.h> namespace search { namespace { -const uint32_t MIN_ALIGNMENT = 4096; +const uint32_t MIN_ALIGNMENT = 4_Ki; } diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index 79e4b1e95ef..19577219e76 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -19,6 +19,7 @@ #include <vespa/searchlib/query/query_term_decoder.h> #include <vespa/searchlib/queryeval/emptysearch.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/searchlib/util/logutil.h> #include <vespa/searchcommon/attribute/attribute_utils.h> #include <thread> @@ -45,7 +46,7 @@ const vespalib::string dataTypeTag = "datatype"; const vespalib::string collectionTypeTag = "collectiontype"; const vespalib::string docIdLimitTag = "docIdLimit"; -constexpr size_t DIRECTIO_ALIGNMENT(4096); +constexpr size_t DIRECTIO_ALIGNMENT(4_Ki); } @@ -643,7 +644,7 @@ IExtendAttribute *AttributeVector::getExtendInterface() { return nullptr; } uint64_t AttributeVector::getEstimatedSaveByteSize() const { - uint64_t headerSize = 4096; + uint64_t headerSize = 4_Ki; uint64_t totalValueCount = _status.getNumValues(); uint64_t uniqueValueCount = _status.getNumUniqueValues(); uint64_t docIdLimit = getCommittedDocIdLimit(); @@ -785,10 +786,10 @@ AttributeVector::update_config(const Config& cfg) if (cfg.getCompactionStrategy() == _config.getCompactionStrategy()) { return; } - drain_hold(1024 * 1024); // Wait until 1MiB or less on hold + drain_hold(1_Mi); // Wait until 1MiB or less on hold _config.setCompactionStrategy(cfg.getCompactionStrategy()); commit(); // might trigger compaction - drain_hold(1024 * 1024); // Wait until 1MiB or less on hold + drain_hold(1_Mi); // Wait until 1MiB or less on hold } template bool AttributeVector::append<StringChangeData>(ChangeVectorT< ChangeTemplate<StringChangeData> > &changes, uint32_t , const StringChangeData &, int32_t, bool); diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp index 72cc6e38fac..7913e617d70 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp @@ -9,6 +9,7 @@ #include <vespa/searchlib/predicate/predicate_index.h> #include <vespa/searchlib/util/fileutil.h> #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.attribute.predicate_attribute"); @@ -134,7 +135,7 @@ PredicateAttribute::onGenerationChange(generation_t generation) void PredicateAttribute::onSave(IAttributeSaveTarget &saveTarget) { LOG(info, "Saving predicate attribute version %d", getVersion()); - IAttributeSaveTarget::Buffer buffer(saveTarget.datWriter().allocBuf(4096)); + IAttributeSaveTarget::Buffer buffer(saveTarget.datWriter().allocBuf(4_Ki)); _index->serialize(*buffer); uint32_t highest_doc_id = static_cast<uint32_t>(_min_feature.size() - 1); buffer->writeInt32(highest_doc_id); diff --git a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp index a396fe9efd8..b55ba221a42 100644 --- a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp @@ -6,6 +6,7 @@ #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchlib/util/filesizecalculator.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP(".search.attribute.readerbase"); @@ -18,7 +19,7 @@ const vespalib::string versionTag = "version"; const vespalib::string docIdLimitTag = "docIdLimit"; const vespalib::string createSerialNumTag = "createSerialNum"; -constexpr size_t DIRECTIO_ALIGNMENT(4096); +constexpr size_t DIRECTIO_ALIGNMENT(4_Ki); uint64_t extractCreateSerialNum(const vespalib::GenericHeader &header) diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp index bbe8c9c8327..2b40150f87b 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp @@ -9,6 +9,7 @@ #include <vespa/searchlib/queryeval/emptysearch.h> #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/vespalib/data/databuffer.h> +#include <vespa/vespalib/util/size_literals.h> namespace search { @@ -244,7 +245,7 @@ SingleBoolAttribute::onShrinkLidSpace() uint64_t SingleBoolAttribute::getEstimatedSaveByteSize() const { - constexpr uint64_t headerSize = 4096 + sizeof(uint32_t); + constexpr uint64_t headerSize = 4_Ki + sizeof(uint32_t); return headerSize + _bv.sizeBytes(); } diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp index 3c26e960a06..92e25097f40 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp @@ -3,6 +3,7 @@ #include "singlenumericattributesaver.h" #include "iattributesavetarget.h" #include <vespa/vespalib/data/databuffer.h> +#include <vespa/vespalib/util/size_literals.h> using vespalib::GenerationHandler; @@ -10,7 +11,7 @@ namespace search { namespace { -const uint32_t MIN_ALIGNMENT = 4096; +const uint32_t MIN_ALIGNMENT = 4_Ki; } diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp index fd2631ac63d..f1d0da42165 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp @@ -8,6 +8,7 @@ #include <vespa/searchlib/query/query_term_simple.h> #include <vespa/searchlib/queryeval/emptysearch.h> #include <vespa/vespalib/data/databuffer.h> +#include <vespa/vespalib/util/size_literals.h> namespace search { @@ -199,7 +200,7 @@ SingleValueSmallNumericAttribute::onShrinkLidSpace() uint64_t SingleValueSmallNumericAttribute::getEstimatedSaveByteSize() const { - uint64_t headerSize = 4096; + uint64_t headerSize = 4_Ki; const size_t numDocs(getCommittedDocIdLimit()); const size_t numDataWords((numDocs + _valueShiftMask) >> _wordShift); const size_t sz((numDataWords + 1) * sizeof(Word)); diff --git a/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp b/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp index 1b4e221d99e..8c1cbc3d672 100644 --- a/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/sourceselector.cpp @@ -3,6 +3,7 @@ #include "sourceselector.h" #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchlib/common/fileheadercontext.h> +#include <vespa/vespalib/util/size_literals.h> using search::queryeval::Source; using vespalib::FileHeader; @@ -82,7 +83,7 @@ SourceSelector::LoadInfo::load() // XXX no checking for success file.ReadOpen(fileName.c_str()); - FileHeader fileHeader(4096); + FileHeader fileHeader(4_Ki); fileHeader.readFile(file); if (fileHeader.hasTag(defaultSourceTag)) { _header._defaultSource = fileHeader.getTag(defaultSourceTag).asInteger(); diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp index 215ee6dabbe..21ce8dc6c06 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp @@ -6,10 +6,11 @@ #include <vespa/vespalib/data/fileheader.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/util/arrayref.h> +#include <vespa/vespalib/util/size_literals.h> namespace search::bitcompression { -uint8_t CodingTables::_log2Table[65536]; +uint8_t CodingTables::_log2Table[64_Ki]; CodingTables tables; // Static initializer @@ -18,7 +19,7 @@ CodingTables::CodingTables() unsigned int x; uint8_t log2Val; - for (x = 0; x < 65536; x++) { + for (x = 0; x < 64_Ki; x++) { unsigned int val = x; for (log2Val = 0; (val >>= 1) != 0; log2Val++) { } @@ -172,7 +173,7 @@ readHeader(vespalib::GenericHeader &header, int64_t fileSize) { size_t hhSize = vespalib::GenericHeader::getMinSize(); assert(static_cast<int64_t>(hhSize) <= fileSize); - vespalib::DataBuffer dataBuffer(32768u); + vespalib::DataBuffer dataBuffer(32_Ki); dataBuffer.ensureFree(hhSize); readBytes(reinterpret_cast<uint8_t *>(dataBuffer.getFree()), hhSize); @@ -297,7 +298,7 @@ void FeatureEncodeContext<bigEndian>:: writeHeader(const vespalib::GenericHeader &header) { - vespalib::DataBuffer dataBuffer(32768u); + vespalib::DataBuffer dataBuffer(32_Ki); vespalib::GenericHeader::BufferWriter bufferWriter(dataBuffer); dataBuffer.ensureFree(header.getSize()); header.write(bufferWriter); diff --git a/searchlib/src/vespa/searchlib/common/documentsummary.cpp b/searchlib/src/vespa/searchlib/common/documentsummary.cpp index 0d00ad1a408..a9cd05a8b0d 100644 --- a/searchlib/src/vespa/searchlib/common/documentsummary.cpp +++ b/searchlib/src/vespa/searchlib/common/documentsummary.cpp @@ -3,6 +3,7 @@ #include "documentsummary.h" #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/searchlib/util/filekit.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/error.h> #include <vespa/log/log.h> @@ -17,7 +18,7 @@ bool DocumentSummary::readDocIdLimit(const vespalib::string &dir, uint32_t &count) { char numbuf[20]; - Fast_BufferedFile qcntfile(4096); + Fast_BufferedFile qcntfile(4_Ki); unsigned int qcnt; vespalib::string qcntname; const char *p; diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp index 33c3b76f1e8..828e38b5267 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/common/bitvector.h> #include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/util/size_literals.h> #include <cassert> namespace search::diskindex { @@ -18,13 +19,13 @@ void readHeader(vespalib::FileHeader &h, const vespalib::string &name) { - Fast_BufferedFile file(32768u); + Fast_BufferedFile file(32_Ki); file.OpenReadOnly(name.c_str()); h.readFile(file); file.Close(); } -const size_t FILE_HEADERSIZE_ALIGNMENT = 4096; +const size_t FILE_HEADERSIZE_ALIGNMENT = 4_Ki; } diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp index 3b778725389..95d2b286d7f 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/common/bitvector.h> #include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/util/size_literals.h> #include <cassert> namespace search::diskindex { @@ -17,13 +18,13 @@ namespace { void readHeader(vespalib::FileHeader &h, const vespalib::string &name) { - Fast_BufferedFile file(32768u); + Fast_BufferedFile file(32_Ki); file.OpenReadOnly(name.c_str()); h.readFile(file); file.Close(); } -const size_t FILE_HEADERSIZE_ALIGNMENT = 4096; +const size_t FILE_HEADERSIZE_ALIGNMENT = 4_Ki; } diff --git a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp index 7621b178634..64fb6142db7 100644 --- a/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/pagedict4file.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/vespalib/io/fileutil.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP(".diskindex.pagedict4file"); @@ -37,7 +38,7 @@ namespace search::diskindex { namespace { -const uint32_t headerAlign = 4096; +const uint32_t headerAlign = 4_Ki; } @@ -211,12 +212,12 @@ PageDict4FileSeqRead::open(const vespalib::string &name, _spReadContext.setFile(&_spfile); _spReadContext.setFileSize(_spfile.GetSize()); - _spReadContext.allocComprBuf(65536u, 32768u); + _spReadContext.allocComprBuf(64_Ki, 32_Ki); _spd.emptyBuffer(0); _pReadContext.setFile(&_pfile); _pReadContext.setFileSize(_pfile.GetSize()); - _pReadContext.allocComprBuf(65536u, 32768u); + _pReadContext.allocComprBuf(64_Ki, 32_Ki); _pd.emptyBuffer(0); uint64_t fileSize = _ssfile.GetSize(); @@ -224,7 +225,7 @@ PageDict4FileSeqRead::open(const vespalib::string &name, _ssReadContext.setFileSize(fileSize); _ssReadContext.allocComprBuf((fileSize + sizeof(uint64_t) - 1) / sizeof(uint64_t), - 32768u); + 32_Ki); _ssd.emptyBuffer(0); _ssReadContext.readComprBuffer(); @@ -357,9 +358,9 @@ PageDict4FileSeqWrite::open(const vespalib::string &name, assertOpenWriteOnly(ok, ssname); _ssWriteContext.setFile(&_ssfile); - _pWriteContext.allocComprBuf(65536u, 32768u); - _spWriteContext.allocComprBuf(65536u, 32768u); - _ssWriteContext.allocComprBuf(65536u, 32768u); + _pWriteContext.allocComprBuf(64_Ki, 32_Ki); + _spWriteContext.allocComprBuf(64_Ki, 32_Ki); + _ssWriteContext.allocComprBuf(64_Ki, 32_Ki); uint64_t pFileSize = _pfile.GetSize(); uint64_t spFileSize = _spfile.GetSize(); diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.cpp b/searchlib/src/vespa/searchlib/docstore/chunk.cpp index f60bf69d908..3d270cc5cc4 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/chunk.cpp @@ -3,6 +3,7 @@ #include "chunk.h" #include "chunkformats.h" #include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/vespalib/util/size_literals.h> namespace search { @@ -59,7 +60,7 @@ Chunk::Chunk(uint32_t id, const Config & config) : _lastSerial(static_cast<uint64_t>(-1l)), _format(std::make_unique<ChunkFormatV2>(config.getMaxBytes())) { - _lids.reserve(4096/sizeof(Entry)); + _lids.reserve(4_Ki/sizeof(Entry)); } Chunk::Chunk(uint32_t id, const void * buffer, size_t len, bool skipcrc) : diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp index 6644533550f..e0a8f4098c6 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp @@ -9,6 +9,7 @@ #include <vespa/vespalib/stllike/cache.hpp> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/util/compressor.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> @@ -76,7 +77,7 @@ BackingStore::visit(const IDocumentStore::LidVector &lids, const DocumentTypeRep bool BackingStore::read(DocumentIdT key, Value &value) const { bool found(false); - vespalib::DataBuffer buf(4096); + vespalib::DataBuffer buf(4_Ki); ssize_t len = _backingStore.read(key, buf); if (len > 0) { value.set(std::move(buf), len, _compression); @@ -355,7 +356,7 @@ void DocumentStore::WrapVisitor<Visitor>::visit(uint32_t lid, const void *buffer, size_t sz) { Value value; - vespalib::DataBuffer buf(4096); + vespalib::DataBuffer buf(4_Ki); buf.clear(); buf.writeBytes(buffer, sz); ssize_t len = sz; diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp index 408286cc8b9..c21dfccccdf 100644 --- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp @@ -6,6 +6,7 @@ #include "randreaders.h" #include <vespa/searchlib/util/filekit.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/stllike/asciistream.h> @@ -343,7 +344,7 @@ FileChunk::appendTo(vespalib::ThreadExecutor & executor, const IGetLid & db, IWr vespalib::GenerationHandler::Guard lidReadGuard(db.getLidReadGuard()); assert(numChunks <= getNumChunks()); FixedParams fixedParams = {db, dest, lidReadGuard, getFileId().getId(), visitorProgress}; - vespalib::BlockingThreadStackExecutor singleExecutor(1, 64*1024, executor.getNumThreads()*2); + vespalib::BlockingThreadStackExecutor singleExecutor(1, 64_Ki, executor.getNumThreads()*2); for (size_t chunkId(0); chunkId < numChunks; chunkId++) { std::promise<Chunk::UP> promisedChunk; std::future<Chunk::UP> futureChunk = promisedChunk.get_future(); diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp index b00b35b4d00..1fc9bc280f8 100644 --- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp @@ -9,6 +9,7 @@ #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/rcuvector.hpp> +#include <vespa/vespalib/util/size_literals.h> #include <thread> #include <vespa/log/log.h> @@ -18,7 +19,7 @@ namespace search { namespace { constexpr size_t DEFAULT_MAX_FILESIZE = 1000000000ul; - constexpr uint32_t DEFAULT_MAX_LIDS_PER_FILE = 32 * 1024 * 1024; + constexpr uint32_t DEFAULT_MAX_LIDS_PER_FILE = 32_Mi; } using vespalib::getLastErrorString; diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp index 8f03bf9e791..f498b93ca14 100644 --- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp @@ -5,6 +5,7 @@ #include "summaryexceptions.h" #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/array.hpp> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/searchlib/common/fileheadercontext.h> @@ -26,8 +27,8 @@ namespace search { namespace { -const uint64_t Alignment = 4096; -const uint64_t headerAlign = 4096; +const uint64_t Alignment = 4_Ki; +const uint64_t headerAlign = 4_Ki; } diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp index 2876fa99434..344e4b72755 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/data/slime/binary_format.h> #include <vespa/vespalib/data/smart_buffer.h> +#include <vespa/vespalib/util/size_literals.h> namespace search::engine { @@ -149,7 +150,7 @@ void ProtoConverter::docsum_reply_to_proto(const DocsumReply &reply, ProtoDocsumReply &proto) { if (reply._root) { - vespalib::SmartBuffer buf(4096); + vespalib::SmartBuffer buf(4_Ki); vespalib::slime::BinaryFormat::encode(*reply._root, buf); proto.set_slime_summaries(buf.obtain().data, buf.obtain().size); } diff --git a/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp b/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp index d229a735f11..0a13b196c43 100644 --- a/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp +++ b/searchlib/src/vespa/searchlib/fef/blueprintresolver.cpp @@ -4,6 +4,7 @@ #include "blueprintfactory.h" #include "featurenameparser.h" #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/size_literals.h> #include <stack> #include <cassert> #include <set> @@ -282,9 +283,9 @@ BlueprintResolver::compile() } }); compile_thread.join(); - int stack_usage = compiler.stack_usage(); - if (stack_usage > (128 * 1024)) { - LOG(warning, "high stack usage: %d bytes", stack_usage); + size_t stack_usage = compiler.stack_usage(); + if (stack_usage > (128_Ki)) { + LOG(warning, "high stack usage: %zu bytes", stack_usage); } return !compiler.failed(); } diff --git a/searchlib/src/vespa/searchlib/fef/rank_program.cpp b/searchlib/src/vespa/searchlib/fef/rank_program.cpp index dd1e774607f..0cc39fa93f3 100644 --- a/searchlib/src/vespa/searchlib/fef/rank_program.cpp +++ b/searchlib/src/vespa/searchlib/fef/rank_program.cpp @@ -4,6 +4,7 @@ #include "featureoverrider.h" #include <vespa/vespalib/locale/c.h> #include <vespa/vespalib/stllike/hash_set.hpp> +#include <vespa/vespalib/util/size_literals.h> #include <algorithm> #include <cassert> @@ -157,7 +158,7 @@ RankProgram::resolve(const BlueprintResolver::FeatureMap &features, bool unbox_s RankProgram::RankProgram(BlueprintResolver::SP resolver) : _resolver(std::move(resolver)), - _hot_stash(32768), + _hot_stash(32_Ki), _cold_stash(), _executors(), _unboxed_seeds(), diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp index d2ac46157b1..2ecf4e8b37a 100644 --- a/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp +++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpcreator.cpp @@ -6,6 +6,7 @@ #include "termnodes.h" #include <vespa/vespalib/objects/nbo.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/searchlib/parsequery/parse.h> using vespalib::string; @@ -271,7 +272,7 @@ class QueryNodeConverter : public QueryVisitor { public: QueryNodeConverter() - : _buf(4096) + : _buf(4_Ki) { } diff --git a/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp index db0bb7f875f..512352270a2 100644 --- a/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/direct_tensor_store.cpp @@ -4,12 +4,13 @@ #include <vespa/eval/eval/value.h> #include <vespa/vespalib/datastore/datastore.hpp> #include <vespa/vespalib/datastore/buffer_type.hpp> +#include <vespa/vespalib/util/size_literals.h> using vespalib::datastore::EntryRef; namespace search::tensor { -constexpr size_t MIN_BUFFER_ARRAYS = 8192; +constexpr size_t MIN_BUFFER_ARRAYS = 8_Ki; DirectTensorStore::TensorBufferType::TensorBufferType() : ParentType(1, MIN_BUFFER_ARRAYS, TensorStoreType::RefType::offsetSize()) diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index 4ad998421ca..31ff3845d74 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -11,6 +11,7 @@ #include <vespa/vespalib/datastore/array_store.hpp> #include <vespa/vespalib/util/memory_allocator.h> #include <vespa/vespalib/util/rcuvector.hpp> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.tensor.hnsw_index"); @@ -23,8 +24,8 @@ using vespalib::datastore::EntryRef; namespace { // TODO: Move this to MemoryAllocator, with name PAGE_SIZE. -constexpr size_t small_page_size = 4 * 1024; -constexpr size_t min_num_arrays_for_new_buffer = 8 * 1024; +constexpr size_t small_page_size = 4_Ki; +constexpr size_t min_num_arrays_for_new_buffer = 8_Ki; constexpr float alloc_grow_factor = 0.2; // TODO: Adjust these numbers to what we accept as max in config. constexpr size_t max_level_array_size = 16; diff --git a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp index 938ba06d445..326ef9d10b7 100644 --- a/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/streamed_value_store.cpp @@ -9,6 +9,7 @@ #include <vespa/vespalib/datastore/buffer_type.hpp> #include <vespa/vespalib/datastore/datastore.hpp> #include <vespa/vespalib/objects/nbostream.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/typify.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/log/log.h> @@ -154,7 +155,7 @@ StreamedValueStore::TensorEntryImpl<CT>::~TensorEntryImpl() = default; //----------------------------------------------------------------------------- -constexpr size_t MIN_BUFFER_ARRAYS = 8192; +constexpr size_t MIN_BUFFER_ARRAYS = 8_Ki; StreamedValueStore::TensorBufferType::TensorBufferType() noexcept : ParentType(1, MIN_BUFFER_ARRAYS, TensorStoreType::RefType::offsetSize()) diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp index 4681861dd73..30e1dc588e1 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp @@ -8,6 +8,7 @@ #include <vespa/searchlib/bitcompression/compression.h> #include <vespa/searchlib/bitcompression/posocccompression.h> #include <vespa/searchlib/bitcompression/posocc_fields_params.h> +#include <vespa/vespalib/util/size_literals.h> using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataPosition; @@ -232,7 +233,7 @@ FakeWord::fakeup(search::BitVector &bitmap, wpf.clear(); for (unsigned int j = 0; j < positions; ++j) { DocWordPosFeature dwpf; - dwpf._wordPos = rnd.lrand48() % 8192; + dwpf._wordPos = rnd.lrand48() % 8_Ki; dwpf._elementId = 0; if (_fieldsParams.getFieldParams()[0]._hasElements) { dwpf._elementId = rnd.lrand48() % 4; @@ -258,7 +259,7 @@ FakeWord::fakeup(search::BitVector &bitmap, lastwordpos = i->_wordPos; ++i; } - uint32_t elementLen = (rnd.lrand48() % 8192) + 1 + lastwordpos; + uint32_t elementLen = (rnd.lrand48() % 8_Ki) + 1 + lastwordpos; int32_t elementWeight = 1; if (_fieldsParams.getFieldParams()[0]. _hasElementWeights) { diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp index a943aa33bf9..1481d1fb191 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fastos/file.h> #include <algorithm> #include <thread> @@ -37,7 +38,7 @@ Domain::Domain(const string &domainName, const string & baseDir, Executor & exec : _config(cfg), _currentChunk(createCommitChunk(cfg)), _lastSerial(0), - _singleCommitter(std::make_unique<vespalib::ThreadStackExecutor>(1, 128 * 1024)), + _singleCommitter(std::make_unique<vespalib::ThreadStackExecutor>(1, 128_Ki)), _executor(executor), _sessionId(1), _syncMonitor(), diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp index 1883943a53f..1d64867fda7 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp @@ -7,6 +7,7 @@ #include <vespa/fnet/frt/rpcrequest.h> #include <vespa/fnet/transport.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fastos/thread.h> @@ -46,10 +47,10 @@ struct RpcTask : public vespalib::Executor::Task { } TransLogClient::TransLogClient(const vespalib::string & rpcTarget) : - _executor(std::make_unique<vespalib::ThreadStackExecutor>(1, 128 * 1024, translogclient_rpc_callback)), + _executor(std::make_unique<vespalib::ThreadStackExecutor>(1, 128_Ki, translogclient_rpc_callback)), _rpcTarget(rpcTarget), _sessions(), - _threadPool(std::make_unique<FastOS_ThreadPool>(1024*60)), + _threadPool(std::make_unique<FastOS_ThreadPool>(60_Ki)), _transport(std::make_unique<FNET_Transport>()), _supervisor(std::make_unique<FRT_Supervisor>(_transport.get())), _target(nullptr) diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp index 891f312151b..ae15147a31c 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fnet/frt/supervisor.h> #include <vespa/fnet/frt/rpcrequest.h> #include <vespa/fnet/transport.h> @@ -96,8 +97,8 @@ TransLogServer::TransLogServer(const vespalib::string &name, int listenPort, con _name(name), _baseDir(baseDir), _domainConfig(cfg), - _executor(maxThreads, 128 * 1024, tls_executor), - _threadPool(std::make_unique<FastOS_ThreadPool>(1024*120)), + _executor(maxThreads, 128_Ki, tls_executor), + _threadPool(std::make_unique<FastOS_ThreadPool>(120_Ki)), _transport(std::make_unique<FNET_Transport>()), _supervisor(std::make_unique<FRT_Supervisor>(_transport.get())), _domains(), diff --git a/searchlib/src/vespa/searchlib/util/comprfile.cpp b/searchlib/src/vespa/searchlib/util/comprfile.cpp index dffcd639a53..3ee402bca2a 100644 --- a/searchlib/src/vespa/searchlib/util/comprfile.cpp +++ b/searchlib/src/vespa/searchlib/util/comprfile.cpp @@ -2,6 +2,7 @@ #include "comprfile.h" #include <vespa/fastos/file.h> +#include <vespa/vespalib/util/size_literals.h> #include <cassert> #include <cstring> @@ -453,7 +454,7 @@ ComprFileWriteContext::allocComprBuf(unsigned int comprBufSize, size_t preferred void ComprFileWriteContext::allocComprBuf() { - allocComprBuf(32768, 32768); + allocComprBuf(32_Ki, 32_Ki); } } diff --git a/searchlib/src/vespa/searchlib/util/dirtraverse.cpp b/searchlib/src/vespa/searchlib/util/dirtraverse.cpp index c414e9c82fd..0ccb8675f37 100644 --- a/searchlib/src/vespa/searchlib/util/dirtraverse.cpp +++ b/searchlib/src/vespa/searchlib/util/dirtraverse.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "dirtraverse.h" +#include <vespa/vespalib/util/size_literals.h> #include <vespa/fastos/file.h> #include <cassert> #include <cstring> @@ -234,7 +235,7 @@ DirectoryTraverse::GetTreeSize() { FastOS_StatInfo statInfo; uint64_t size = 0; - const uint64_t blockSize = 4096; + const uint64_t blockSize = 4_Ki; while (NextName()) { const char *relname = GetRelName(); diff --git a/searchlib/src/vespa/searchlib/util/filealign.cpp b/searchlib/src/vespa/searchlib/util/filealign.cpp index 1a277adc113..03b18533168 100644 --- a/searchlib/src/vespa/searchlib/util/filealign.cpp +++ b/searchlib/src/vespa/searchlib/util/filealign.cpp @@ -2,6 +2,7 @@ #include "filealign.h" #include <vespa/fastos/file.h> +#include <vespa/vespalib/util/size_literals.h> #include <cassert> namespace search { @@ -97,8 +98,8 @@ FileAlign::setupAlign(size_t elements, _directIOFileAlign = 1; _directIOMemAlign = 1; } - if (preferredFileAlignment < 4096) - preferredFileAlignment = 4096; + if (preferredFileAlignment < 4_Ki) + preferredFileAlignment = 4_Ki; _preferredFileAlign = preferredFileAlignment; size_t minDirectIOElements = getMinBlocking(elemSize, _directIOFileAlign); |