diff options
37 files changed, 122 insertions, 86 deletions
diff --git a/staging_vespalib/src/tests/directio/directio.cpp b/staging_vespalib/src/tests/directio/directio.cpp index 04155f71f94..7877216b191 100644 --- a/staging_vespalib/src/tests/directio/directio.cpp +++ b/staging_vespalib/src/tests/directio/directio.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/fastos/file.h> @@ -21,12 +22,12 @@ TEST("that DirectIOException is thrown on unaligned buf.") { FastOS_File f("staging_vespalib_directio_test_app"); f.EnableDirectIO(); EXPECT_TRUE(f.OpenReadOnly()); - DataBuffer buf(10000, 4096); + DataBuffer buf(10000, 4_Ki); bool caught(false); try { - f.ReadBuf(buf.getFree()+1, 4096, 0); + f.ReadBuf(buf.getFree()+1, 4_Ki, 0); } catch (const DirectIOException & e) { - EXPECT_EQUAL(4096u, e.getLength()); + EXPECT_EQUAL(4_Ki, e.getLength()); EXPECT_EQUAL(0u, e.getOffset()); EXPECT_EQUAL(buf.getFree()+1, e.getBuffer()); EXPECT_EQUAL(string(f.GetFileName()), e.getFileName()); @@ -39,12 +40,12 @@ TEST("that DirectIOException is thrown on unaligned offset.") { FastOS_File f("staging_vespalib_directio_test_app"); f.EnableDirectIO(); EXPECT_TRUE(f.OpenReadOnly()); - DataBuffer buf(10000, 4096); + DataBuffer buf(10000, 4_Ki); bool caught(false); try { - f.ReadBuf(buf.getFree(), 4096, 1); + f.ReadBuf(buf.getFree(), 4_Ki, 1); } catch (const DirectIOException & e) { - EXPECT_EQUAL(4096u, e.getLength()); + EXPECT_EQUAL(4_Ki, e.getLength()); EXPECT_EQUAL(1u, e.getOffset()); EXPECT_EQUAL(buf.getFree(), e.getBuffer()); EXPECT_EQUAL(string(f.GetFileName()), e.getFileName()); diff --git a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp index e4274664336..0d33a27edbf 100644 --- a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp +++ b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/process_memory_stats.h> +#include <vespa/vespalib/util/size_literals.h> #include <iostream> #include <fstream> #include <sys/mman.h> @@ -41,7 +42,7 @@ TEST("grow anonymous memory") { ProcessMemoryStats stats1(ProcessMemoryStats::create(SIZE_EPSILON)); std::cout << toString(stats1) << std::endl; - size_t mapLen = 64 * 1024; + size_t mapLen = 64_Ki; void *mapAddr = mmap(nullptr, mapLen, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); EXPECT_NOT_EQUAL(reinterpret_cast<void *>(-1), mapAddr); @@ -59,7 +60,7 @@ TEST("grow anonymous memory") TEST("grow mapped memory") { std::ofstream of("mapfile"); - size_t mapLen = 64 * 1024; + size_t mapLen = 64_Ki; std::vector<char> buf(mapLen, 4); of.write(&buf[0], buf.size()); of.close(); diff --git a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp index 3f5b3b79656..9cd2ff59b49 100644 --- a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp @@ -3,6 +3,7 @@ #include <vespa/fnet/scheduler.h> #include <vespa/fnet/task.h> #include <vespa/fnet/transport.h> +#include <vespa/vespalib/util/size_literals.h> namespace vespalib { @@ -35,7 +36,7 @@ public: }; ScheduledExecutor::ScheduledExecutor() - : _threadPool(128 * 1024), + : _threadPool(128_Ki), _transport(new FNET_Transport()), _lock(), _taskList() diff --git a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp index b0c67e14c5b..102fdeb1d4e 100644 --- a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp @@ -4,6 +4,7 @@ #include "adaptive_sequenced_executor.h" #include "singleexecutor.h" #include <vespa/vespalib/util/blockingthreadstackexecutor.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/stllike/hashtable.h> #include <cassert> @@ -11,7 +12,7 @@ namespace vespalib { namespace { -constexpr uint32_t stackSize = 128 * 1024; +constexpr uint32_t stackSize = 128_Ki; constexpr uint8_t MAGIC = 255; bool diff --git a/vespalib/src/apps/vespa-detect-hostname/detect_hostname.cpp b/vespalib/src/apps/vespa-detect-hostname/detect_hostname.cpp index d65c8f20e12..86f615f407b 100644 --- a/vespalib/src/apps/vespa-detect-hostname/detect_hostname.cpp +++ b/vespalib/src/apps/vespa-detect-hostname/detect_hostname.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/net/socket_address.h> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/size_literals.h> #include <set> using vespalib::SocketAddress; @@ -18,7 +19,7 @@ std::set<vespalib::string> make_ip_set() { } vespalib::string get_hostname() { - std::vector<char> result(4096, '\0'); + std::vector<char> result(4_Ki, '\0'); gethostname(&result[0], 4000); return SocketAddress::normalize(&result[0]); } diff --git a/vespalib/src/tests/alloc/alloc_test.cpp b/vespalib/src/tests/alloc/alloc_test.cpp index 056bac58d28..c52170fc8ec 100644 --- a/vespalib/src/tests/alloc/alloc_test.cpp +++ b/vespalib/src/tests/alloc/alloc_test.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/util/alloc.h> #include <vespa/vespalib/util/mmap_file_allocator.h> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/size_literals.h> #include <cstddef> #include <sys/mman.h> @@ -24,11 +25,11 @@ testSwap(T & a, T & b) { void * tmpA(a.get()); void * tmpB(b.get()); - EXPECT_EQUAL(4096ul, a.size()); - EXPECT_EQUAL(8192ul, b.size()); + EXPECT_EQUAL(4_Ki, a.size()); + EXPECT_EQUAL(8_Ki, b.size()); std::swap(a, b); - EXPECT_EQUAL(4096ul, b.size()); - EXPECT_EQUAL(8192ul, a.size()); + EXPECT_EQUAL(4_Ki, b.size()); + EXPECT_EQUAL(8_Ki, a.size()); EXPECT_EQUAL(tmpA, b.get()); EXPECT_EQUAL(tmpB, a.get()); } @@ -54,30 +55,30 @@ TEST("test basics") { } { EXPECT_EXCEPTION(Alloc::allocAlignedHeap(100, 7), IllegalArgumentException, "Alloc::allocAlignedHeap(100, 7) does not support 7 alignment"); - Alloc h = Alloc::allocAlignedHeap(100, 1024); + Alloc h = Alloc::allocAlignedHeap(100, 1_Ki); EXPECT_EQUAL(100u, h.size()); EXPECT_TRUE(h.get() != nullptr); } { Alloc h = Alloc::allocMMap(100); - EXPECT_EQUAL(4096u, h.size()); + EXPECT_EQUAL(4_Ki, h.size()); EXPECT_TRUE(h.get() != nullptr); } { - Alloc a = Alloc::allocHeap(4096), b = Alloc::allocHeap(8192); + Alloc a = Alloc::allocHeap(4_Ki), b = Alloc::allocHeap(8_Ki); testSwap(a, b); } { - Alloc a = Alloc::allocMMap(4096), b = Alloc::allocMMap(8192); + Alloc a = Alloc::allocMMap(4_Ki), b = Alloc::allocMMap(8_Ki); testSwap(a, b); } { - Alloc a = Alloc::allocAlignedHeap(4096, 1024), b = Alloc::allocAlignedHeap(8192, 1024); + Alloc a = Alloc::allocAlignedHeap(4_Ki, 1_Ki), b = Alloc::allocAlignedHeap(8_Ki, 1_Ki); testSwap(a, b); } { - Alloc a = Alloc::allocHeap(4096); - Alloc b = Alloc::allocMMap(8192); + Alloc a = Alloc::allocHeap(4_Ki); + Alloc b = Alloc::allocMMap(8_Ki); testSwap(a, b); } { @@ -90,8 +91,8 @@ TEST("test basics") { TEST("test correct alignment") { { - Alloc buf = Alloc::alloc(10, MemoryAllocator::HUGEPAGE_SIZE, 1024); - EXPECT_TRUE(reinterpret_cast<ptrdiff_t>(buf.get()) % 1024 == 0); + Alloc buf = Alloc::alloc(10, MemoryAllocator::HUGEPAGE_SIZE, 1_Ki); + EXPECT_TRUE(reinterpret_cast<ptrdiff_t>(buf.get()) % 1_Ki == 0); } { @@ -215,7 +216,7 @@ TEST("mmap alloc can be extended if room") { Alloc buf = Alloc::allocMMap(100); TEST_DO(ensureRoomForExtension(buf, reserved)); - TEST_DO(verifyExtension(buf, 4096, 4096*2)); + TEST_DO(verifyExtension(buf, 4_Ki, 4_Ki*2)); } TEST("mmap alloc can not be extended if no room") { @@ -223,7 +224,7 @@ TEST("mmap alloc can not be extended if no room") { Alloc reserved = Alloc::allocMMap(100); Alloc buf = Alloc::allocMMap(100); - TEST_DO(verifyNoExtensionWhenNoRoom(buf, reserved, 4096)); + TEST_DO(verifyNoExtensionWhenNoRoom(buf, reserved, 4_Ki)); } #endif #endif @@ -240,10 +241,10 @@ TEST("heap alloc can not be shrinked") { TEST("mmap alloc can be shrinked") { Alloc buf = Alloc::allocMMap(4097); void * oldPtr = buf.get(); - EXPECT_EQUAL(8192ul, buf.size()); + EXPECT_EQUAL(8_Ki, buf.size()); EXPECT_TRUE(buf.resize_inplace(4095)); EXPECT_EQUAL(oldPtr, buf.get()); - EXPECT_EQUAL(4096ul, buf.size()); + EXPECT_EQUAL(4_Ki, buf.size()); } TEST("auto alloced heap alloc can not be shrinked") { diff --git a/vespalib/src/tests/array/array_test.cpp b/vespalib/src/tests/array/array_test.cpp index a5dfd1472a6..e5294b3243b 100644 --- a/vespalib/src/tests/array/array_test.cpp +++ b/vespalib/src/tests/array/array_test.cpp @@ -1,8 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/util/array.hpp> #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/array.hpp> +#include <vespa/vespalib/util/size_literals.h> #include <deque> #include <atomic> @@ -139,14 +140,14 @@ TEST("test that organic growth is by 2 in N and reserve resize are exact") EXPECT_EQUAL(512u, c.capacity()); c.push_back('j'); EXPECT_EQUAL(513u, c.size()); - EXPECT_EQUAL(1024u, c.capacity()); + EXPECT_EQUAL(1_Ki, c.capacity()); for(size_t i(513); i < 1024; i++) { c.push_back('a'); } - EXPECT_EQUAL(1024u, c.size()); - EXPECT_EQUAL(1024u, c.capacity()); + EXPECT_EQUAL(1_Ki, c.size()); + EXPECT_EQUAL(1_Ki, c.capacity()); c.reserve(1025); - EXPECT_EQUAL(1024u, c.size()); + EXPECT_EQUAL(1_Ki, c.size()); EXPECT_EQUAL(1025u, c.capacity()); c.push_back('b'); // Within, no growth EXPECT_EQUAL(1025u, c.size()); @@ -345,7 +346,7 @@ TEST_F("require that try_unreserve() succeedes if mmap can be shrinked", Unreser int *oldPtr = &f.arr[0]; f.arr.resize(512); EXPECT_TRUE(f.arr.try_unreserve(1023)); - EXPECT_EQUAL(1024u, f.arr.capacity()); + EXPECT_EQUAL(1_Ki, f.arr.capacity()); int *newPtr = &f.arr[0]; EXPECT_EQUAL(oldPtr, newPtr); } diff --git a/vespalib/src/tests/data/databuffer/databuffer_test.cpp b/vespalib/src/tests/data/databuffer/databuffer_test.cpp index f440ca1e15c..80f3e9e9b86 100644 --- a/vespalib/src/tests/data/databuffer/databuffer_test.cpp +++ b/vespalib/src/tests/data/databuffer/databuffer_test.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 <vespa/vespalib/testkit/testapp.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/databuffer.h> #include <iostream> @@ -28,7 +29,7 @@ Test::testBasic() EXPECT_EQUAL(256u, a.getBufSize()); EXPECT_EQUAL(a.getFreeLen(), a.getBufSize()); a.ensureFree(1000); - EXPECT_EQUAL(1024u, a.getBufSize()); + EXPECT_EQUAL(1_Ki, a.getBufSize()); EXPECT_EQUAL(a.getFreeLen(), a.getBufSize()); EXPECT_EQUAL(0u, a.getDeadLen()); EXPECT_EQUAL(0u, a.getDataLen()); diff --git a/vespalib/src/tests/datastore/array_store/array_store_test.cpp b/vespalib/src/tests/datastore/array_store/array_store_test.cpp index 72f803b441b..bf2ca9629c2 100644 --- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp +++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/util/memory_allocator.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/traits.h> #include <vector> @@ -35,7 +36,7 @@ struct Fixture generation_t generation; Fixture(uint32_t maxSmallArraySize, bool enable_free_lists = true) : store(ArrayStoreConfig(maxSmallArraySize, - ArrayStoreConfig::AllocSpec(16, RefT::offsetSize(), 8 * 1024, + ArrayStoreConfig::AllocSpec(16, RefT::offsetSize(), 8_Ki, ALLOC_GROW_FACTOR)).enable_free_lists(enable_free_lists)), refStore(), generation(1) @@ -403,7 +404,7 @@ TEST_F("require that address space usage is ratio between used arrays and number TEST_F("require that offset in EntryRefT is within bounds when allocating memory buffers where wanted number of bytes is not a power of 2 and less than huge page size", ByteFixture(ByteFixture::ArrayStoreType::optimizedConfigForHugePage(1023, vespalib::alloc::MemoryAllocator::HUGEPAGE_SIZE, - 4 * 1024, 8 * 1024, ALLOC_GROW_FACTOR))) + 4_Ki, 8_Ki, ALLOC_GROW_FACTOR))) { // The array store config used in this test is equivalent to the one multi-value attribute uses when initializing multi-value mapping. // See similar test in datastore_test.cpp for more details on what happens during memory allocation. diff --git a/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp b/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp index e90149ed08f..a2a1ee91d57 100644 --- a/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp +++ b/vespalib/src/tests/datastore/array_store_config/array_store_config_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/datastore/entryref.h> #include <vespa/vespalib/datastore/array_store_config.h> +#include <vespa/vespalib/util/size_literals.h> using namespace vespalib::datastore; using AllocSpec = ArrayStoreConfig::AllocSpec; @@ -64,7 +65,7 @@ TEST_F("require that we can generate config optimized for a given huge page", Fi 4 * KB, 8 * KB)) { - EXPECT_EQUAL(1024u, f.cfg.maxSmallArraySize()); + EXPECT_EQUAL(1_Ki, f.cfg.maxSmallArraySize()); TEST_DO(f.assertSpec(0, 8 * KB)); // large arrays TEST_DO(f.assertSpec(1, 256 * KB)); TEST_DO(f.assertSpec(2, 256 * KB)); diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp index 0739fd24235..2024a440627 100644 --- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp +++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/test/memory_allocator_observer.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/log/log.h> LOG_SETUP("datastore_test"); @@ -143,8 +144,8 @@ assertMemStats(const DataStoreBase::MemStats &exp, TEST(DataStoreTest, require_that_entry_ref_is_working) { using MyRefType = EntryRefT<22>; - EXPECT_EQ(4194304u, MyRefType::offsetSize()); - EXPECT_EQ(1024u, MyRefType::numBuffers()); + EXPECT_EQ(4_Mi, MyRefType::offsetSize()); + EXPECT_EQ(1_Ki, MyRefType::numBuffers()); { MyRefType r(0, 0); EXPECT_EQ(0u, r.offset()); @@ -171,8 +172,8 @@ TEST(DataStoreTest, require_that_entry_ref_is_working) TEST(DataStoreTest, require_that_aligned_entry_ref_is_working) { using MyRefType = AlignedEntryRefT<22, 2>; // 4 byte alignement - EXPECT_EQ(4 * 4194304u, MyRefType::offsetSize()); - EXPECT_EQ(1024u, MyRefType::numBuffers()); + EXPECT_EQ(16_Mi, MyRefType::offsetSize()); + EXPECT_EQ(1_Ki, MyRefType::numBuffers()); EXPECT_EQ(0u, MyRefType::align(0)); EXPECT_EQ(4u, MyRefType::align(1)); EXPECT_EQ(4u, MyRefType::align(2)); diff --git a/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp b/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp index a0ef200ab83..e26a0931090 100644 --- a/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp +++ b/vespalib/src/tests/executor/blockingthreadstackexecutor_test.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/util/blockingthreadstackexecutor.h> #include <vespa/vespalib/util/executor.h> #include <vespa/vespalib/util/backtrace.h> +#include <vespa/vespalib/util/size_literals.h> #include <thread> using namespace vespalib; @@ -122,14 +123,14 @@ vespalib::string get_worker_stack_trace(BlockingThreadStackExecutor &executor) { VESPA_THREAD_STACK_TAG(my_stack_tag); -TEST_F("require that executor has appropriate default thread stack tag", BlockingThreadStackExecutor(1, 128*1024, 10)) { +TEST_F("require that executor has appropriate default thread stack tag", BlockingThreadStackExecutor(1, 128_Ki, 10)) { vespalib::string trace = get_worker_stack_trace(f1); if (!EXPECT_TRUE(trace.find("unnamed_blocking_executor") != vespalib::string::npos)) { fprintf(stderr, "%s\n", trace.c_str()); } } -TEST_F("require that executor thread stack tag can be set", BlockingThreadStackExecutor(1, 128*1024, 10, my_stack_tag)) { +TEST_F("require that executor thread stack tag can be set", BlockingThreadStackExecutor(1, 128_Ki, 10, my_stack_tag)) { vespalib::string trace = get_worker_stack_trace(f1); if (!EXPECT_TRUE(trace.find("my_stack_tag") != vespalib::string::npos)) { fprintf(stderr, "%s\n", trace.c_str()); @@ -139,7 +140,7 @@ TEST_F("require that executor thread stack tag can be set", BlockingThreadStackE TEST_F("require that tasks posted from internal worker thread will not block executor", TimeBomb(60)) { size_t cnt = 0; Gate fork_done; - BlockingThreadStackExecutor executor(1, 128*1024, 10); + BlockingThreadStackExecutor executor(1, 128_Ki, 10); struct IncTask : Executor::Task { size_t &cnt; IncTask(size_t &cnt_in) : cnt(cnt_in) {} diff --git a/vespalib/src/tests/executor/threadstackexecutor_test.cpp b/vespalib/src/tests/executor/threadstackexecutor_test.cpp index e860a25c83c..a830a7a6c2b 100644 --- a/vespalib/src/tests/executor/threadstackexecutor_test.cpp +++ b/vespalib/src/tests/executor/threadstackexecutor_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/backtrace.h> +#include <vespa/vespalib/util/size_literals.h> #include <atomic> using namespace vespalib; @@ -171,14 +172,14 @@ vespalib::string get_worker_stack_trace(ThreadStackExecutor &executor) { VESPA_THREAD_STACK_TAG(my_stack_tag); -TEST_F("require that executor has appropriate default thread stack tag", ThreadStackExecutor(1, 128*1024)) { +TEST_F("require that executor has appropriate default thread stack tag", ThreadStackExecutor(1, 128_Ki)) { vespalib::string trace = get_worker_stack_trace(f1); if (!EXPECT_TRUE(trace.find("unnamed_nonblocking_executor") != vespalib::string::npos)) { fprintf(stderr, "%s\n", trace.c_str()); } } -TEST_F("require that executor thread stack tag can be set", ThreadStackExecutor(1, 128*1024, my_stack_tag)) { +TEST_F("require that executor thread stack tag can be set", ThreadStackExecutor(1, 128_Ki, my_stack_tag)) { vespalib::string trace = get_worker_stack_trace(f1); if (!EXPECT_TRUE(trace.find("my_stack_tag") != vespalib::string::npos)) { fprintf(stderr, "%s\n", trace.c_str()); diff --git a/vespalib/src/tests/io/fileutil/fileutiltest.cpp b/vespalib/src/tests/io/fileutil/fileutiltest.cpp index 0aaa84c0585..6f0308a3003 100644 --- a/vespalib/src/tests/io/fileutil/fileutiltest.cpp +++ b/vespalib/src/tests/io/fileutil/fileutiltest.cpp @@ -5,6 +5,7 @@ #include <vector> #include <regex> #include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/util/size_literals.h> namespace vespalib { @@ -406,7 +407,7 @@ TEST("require that vespalib::copy works") MallocAutoPtr buffer = getAlignedBuffer(5000); memset(buffer.get(), 0, 5000); strncpy(static_cast<char*>(buffer.get()), "Hello World!\n", 14); - f.write(buffer.get(), 4096, 0); + f.write(buffer.get(), 4_Ki, 0); f.close(); std::cerr << "Simple copy\n"; // Simple copy works (4096b dividable file) diff --git a/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp b/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp index 7230f97818f..ca1d5559bce 100644 --- a/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp +++ b/vespalib/src/tests/net/crypto_socket/crypto_socket_test.cpp @@ -13,6 +13,7 @@ #include <vespa/vespalib/net/socket_utils.h> #include <vespa/vespalib/data/smart_buffer.h> #include <vespa/vespalib/test/make_tls_options_for_testing.h> +#include <vespa/vespalib/util/size_literals.h> #include <sys/types.h> #include <sys/socket.h> #include <fcntl.h> @@ -38,7 +39,7 @@ bool is_blocked(int res) { } void read(CryptoSocket &socket, SmartBuffer &buffer) { - size_t chunk_size = std::max(size_t(4096), socket.min_read_buffer_size()); + size_t chunk_size = std::max(size_t(4_Ki), socket.min_read_buffer_size()); auto chunk = buffer.reserve(chunk_size); int res = socket.read(chunk.data, chunk.size); if (res > 0) { @@ -50,7 +51,7 @@ void read(CryptoSocket &socket, SmartBuffer &buffer) { void drain(CryptoSocket &socket, SmartBuffer &buffer) { int res; - size_t chunk_size = std::max(size_t(4096), socket.min_read_buffer_size()); + size_t chunk_size = std::max(size_t(4_Ki), socket.min_read_buffer_size()); do { auto chunk = buffer.reserve(chunk_size); res = socket.drain(chunk.data, chunk.size); @@ -105,7 +106,7 @@ void read_EOF(CryptoSocket &socket, SmartBuffer &read_buffer) { ASSERT_EQUAL(read_buffer.obtain().size, 0u); SingleFdSelector selector(socket.get_fd()); ASSERT_TRUE(selector.wait_readable()); - size_t chunk_size = std::max(size_t(4096), socket.min_read_buffer_size()); + size_t chunk_size = std::max(size_t(4_Ki), socket.min_read_buffer_size()); auto chunk = read_buffer.reserve(chunk_size); auto res = socket.read(chunk.data, chunk.size); while (is_blocked(res)) { @@ -205,7 +206,7 @@ void verify_handshake(CryptoSocket &socket) { void verify_crypto_socket(SocketPair &sockets, CryptoEngine &engine, bool is_server) { SocketHandle &my_handle = is_server ? sockets.server : sockets.client; my_handle.set_blocking(false); - SmartBuffer read_buffer(4096); + SmartBuffer read_buffer(4_Ki); CryptoSocket::UP my_socket = is_server ? engine.create_server_crypto_socket(std::move(my_handle)) : engine.create_client_crypto_socket(std::move(my_handle), local_spec); diff --git a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp index 7dacbd89503..92099e9a602 100644 --- a/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp +++ b/vespalib/src/tests/net/tls/openssl_impl/openssl_impl_test.cpp @@ -12,6 +12,7 @@ #include <vespa/vespalib/net/tls/impl/openssl_tls_context_impl.h> #include <vespa/vespalib/test/make_tls_options_for_testing.h> #include <vespa/vespalib/test/peer_policy_utils.h> +#include <vespa/vespalib/util/size_literals.h> #include <stdexcept> #include <stdlib.h> @@ -83,8 +84,8 @@ struct Fixture { tls_ctx(TlsContext::create_default_context(tls_opts, AuthorizationMode::Enforce)), client(create_openssl_codec(tls_ctx, CryptoCodec::Mode::Client)), server(create_openssl_codec(tls_ctx, CryptoCodec::Mode::Server)), - client_to_server(64 * 1024), - server_to_client(64 * 1024) + client_to_server(64_Ki), + server_to_client(64_Ki) {} ~Fixture(); diff --git a/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp b/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp index 97c767a17ed..3f36bbf6401 100644 --- a/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp +++ b/vespalib/src/tests/shared_string_repo/shared_string_repo_test.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/util/shared_string_repo.h> #include <vespa/vespalib/util/rendezvous.h> #include <vespa/vespalib/util/time.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/testkit/test_kit.h> @@ -18,7 +19,7 @@ using Stats = SharedStringRepo::Stats; bool verbose = false; double budget = 0.10; -size_t work_size = 4096; +size_t work_size = 4_Ki; //----------------------------------------------------------------------------- diff --git a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp index f1021ba3b09..7e8bcdcc5f4 100644 --- a/vespalib/src/tests/simple_thread_bundle/threading_speed_test.cpp +++ b/vespalib/src/tests/simple_thread_bundle/threading_speed_test.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 <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/simple_thread_bundle.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/box.h> #include <thread> @@ -8,7 +9,7 @@ using namespace vespalib; uint64_t doWork(uint64_t data) { uint64_t value = data; - for (size_t i = 0; i < 1024 * 1024; ++i) { + for (size_t i = 0; i < 1_Mi; ++i) { value = (value << 16) + (value >> 8) + (value << 32); } return value; diff --git a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp index dc31f4b8b42..a7f6aa06e26 100644 --- a/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp +++ b/vespalib/src/tests/slime/summary-feature-benchmark/summary-feature-benchmark.cpp @@ -1,5 +1,6 @@ // 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/util/size_literals.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/data/slime/slime.h> @@ -9,7 +10,7 @@ using namespace vespalib::slime::convenience; struct MyBuffer : public Output { std::vector<char> data; size_t used; - MyBuffer() : data(1024 * 1024), used(0) {} + MyBuffer() : data(1_Mi), used(0) {} ~MyBuffer(); WritableMemory reserve(size_t bytes) override { assert(data.size() >= (used + bytes)); diff --git a/vespalib/src/tests/stash/stash.cpp b/vespalib/src/tests/stash/stash.cpp index cea359a1bab..65de2ed8030 100644 --- a/vespalib/src/tests/stash/stash.cpp +++ b/vespalib/src/tests/stash/stash.cpp @@ -1,5 +1,6 @@ // 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/util/size_literals.h> #include <vespa/vespalib/util/stash.h> #include <vespa/vespalib/util/traits.h> @@ -171,7 +172,7 @@ TEST("require that large object creation and destruction works") { Stash stash; stash.create<Large>(destructed); EXPECT_EQUAL(0u, stash.count_used()); - EXPECT_GREATER(sizeof(Large), 1024u); + EXPECT_GREATER(sizeof(Large), 1_Ki); EXPECT_FALSE(destructed); } EXPECT_TRUE(destructed); @@ -193,7 +194,7 @@ TEST("require that large objects can skip destruction") { Stash stash; stash.create<Large_NoDelete>(destructed); EXPECT_EQUAL(0u, stash.count_used()); - EXPECT_GREATER(sizeof(Large_NoDelete), 1024u); + EXPECT_GREATER(sizeof(Large_NoDelete), 1_Ki); } EXPECT_FALSE(destructed); } @@ -243,9 +244,9 @@ TEST("require that multiple chunks can be used by the stash") { EXPECT_EQUAL(100 * 512 + count * chunk_header_size(), stash.count_used()); } -TEST("require that default chunk size is 4096") { +TEST("require that default chunk size is 4_Ki") { Stash stash; - EXPECT_EQUAL(4096u, stash.get_chunk_size()); + EXPECT_EQUAL(4_Ki, stash.get_chunk_size()); } TEST("require that the chunk size can be adjusted") { @@ -460,7 +461,7 @@ void check_array(ArrayRef<float> arr, size_t expect_size) { } TEST("require that uninitialized arrays can be created") { - Stash stash(4096); + Stash stash(4_Ki); EXPECT_EQUAL(0u, stash.count_used()); ArrayRef<float> small_arr = stash.create_uninitialized_array<float>(64); TEST_DO(check_array(small_arr, 64)); diff --git a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp index 2c1463e506a..f606b7aa39e 100644 --- a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp +++ b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp @@ -2,9 +2,9 @@ #include <vespa/log/log.h> LOG_SETUP("generation_handler_stress_test"); #include <vespa/vespalib/testkit/testapp.h> - #include <vespa/vespalib/util/generationhandler.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <vespa/vespalib/util/size_literals.h> using vespalib::Executor; using vespalib::GenerationHandler; @@ -52,8 +52,8 @@ private: Fixture::Fixture(uint32_t readThreads) : _generationHandler(), _readThreads(readThreads), - _writer(1, 128 * 1024), - _readers(readThreads, 128 * 1024), + _writer(1, 128_Ki), + _readers(readThreads, 128_Ki), _doneWriteWork(0), _doneReadWork(0), _stopRead(0), diff --git a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp b/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp index 4cbfbfebd3c..d0f319d4a0b 100644 --- a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp +++ b/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/rcuvector.h> +#include <vespa/vespalib/util/size_literals.h> using namespace vespalib; @@ -241,13 +242,13 @@ struct ShrinkFixture { GenerationHolder g; RcuVectorBase<int> vec; int *oldPtr; - ShrinkFixture() : g(), vec(4096, 50, 0, g, alloc::Alloc::allocMMap()), oldPtr() + ShrinkFixture() : g(), vec(4_Ki, 50, 0, g, alloc::Alloc::allocMMap()), oldPtr() { for (size_t i = 0; i < 4000; ++i) { vec.push_back(7); } EXPECT_EQUAL(4000u, vec.size()); - EXPECT_EQUAL(4096u, vec.capacity()); + EXPECT_EQUAL(4_Ki, vec.capacity()); assertEmptyHoldList(); oldPtr = &vec[0]; } @@ -263,7 +264,7 @@ TEST_F("require that shrink() does not increase allocated memory", ShrinkFixture { f.vec.shrink(2732); EXPECT_EQUAL(2732u, f.vec.size()); - EXPECT_EQUAL(4096u, f.vec.capacity()); + EXPECT_EQUAL(4_Ki, f.vec.capacity()); TEST_DO(f.assertOldEqualNewBuffer()); TEST_DO(f.assertEmptyHoldList()); } diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp index b54c54e9bcc..7260a50609f 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp @@ -5,10 +5,11 @@ #include "unique_store_allocator.h" #include "unique_store_value_filter.h" #include "datastore.hpp" +#include <vespa/vespalib/util/size_literals.h> namespace vespalib::datastore { -constexpr size_t NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER = 1024u; +constexpr size_t NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER = 1_Ki; constexpr float ALLOC_GROW_FACTOR = 0.2; template <typename EntryT, typename RefT> diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp b/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp index b828db081ba..da6bc60d72f 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.cpp @@ -2,12 +2,13 @@ #include "unique_store_string_allocator.hpp" #include "buffer_type.hpp" +#include <vespa/vespalib/util/size_literals.h> namespace vespalib::datastore { namespace { -constexpr size_t NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER = 1024u; +constexpr size_t NUM_ARRAYS_FOR_NEW_UNIQUESTORE_BUFFER = 1_Ki; constexpr float ALLOC_GROW_FACTOR = 0.2; } diff --git a/vespalib/src/vespa/vespalib/io/fileutil.cpp b/vespalib/src/vespa/vespalib/io/fileutil.cpp index 5840b621a6c..17ca6d7e488 100644 --- a/vespalib/src/vespa/vespalib/io/fileutil.cpp +++ b/vespalib/src/vespa/vespalib/io/fileutil.cpp @@ -3,6 +3,7 @@ #include "fileutil.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/fastos/file.h> #include <ostream> @@ -369,7 +370,7 @@ File::readAll() const // Limit ourselves to 4K on the stack. If this becomes a problem we should // allocate on the heap. - char buffer[4096]; + char buffer[4_Ki]; off_t offset = 0; while (true) { @@ -702,8 +703,8 @@ rename(const string & frompath, const string & topath, namespace { - uint32_t bufferSize = 1024 * 1024; - uint32_t diskAlignmentSize = 4096; + uint32_t bufferSize = 1_Mi; + uint32_t diskAlignmentSize = 4_Ki; } diff --git a/vespalib/src/vespa/vespalib/net/async_resolver.cpp b/vespalib/src/vespa/vespalib/net/async_resolver.cpp index c9ff9588fba..d775f99ce77 100644 --- a/vespalib/src/vespa/vespalib/net/async_resolver.cpp +++ b/vespalib/src/vespa/vespalib/net/async_resolver.cpp @@ -2,6 +2,7 @@ #include "async_resolver.h" #include "socket_spec.h" +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/log/log.h> @@ -150,7 +151,7 @@ AsyncResolver::SP AsyncResolver::_shared_resolver(nullptr); AsyncResolver::AsyncResolver(HostResolver::SP resolver, size_t num_threads) : _resolver(std::move(resolver)), - _executor(std::make_unique<ThreadStackExecutor>(num_threads, 128*1024, async_resolver_executor_thread)) + _executor(std::make_unique<ThreadStackExecutor>(num_threads, 128_Ki, async_resolver_executor_thread)) { } diff --git a/vespalib/src/vespa/vespalib/net/crypto_engine.cpp b/vespalib/src/vespa/vespalib/net/crypto_engine.cpp index 7bbc4b7523c..81ff28f17a1 100644 --- a/vespalib/src/vespa/vespalib/net/crypto_engine.cpp +++ b/vespalib/src/vespa/vespalib/net/crypto_engine.cpp @@ -11,6 +11,7 @@ #include <vespa/vespalib/net/tls/transport_security_options.h> #include <vespa/vespalib/net/tls/transport_security_options_reading.h> #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/size_literals.h> #include <vector> #include <chrono> #include <thread> @@ -57,7 +58,7 @@ public: class XorCryptoSocket : public CryptoSocket { private: - static constexpr size_t CHUNK_SIZE = 16 * 1024; + static constexpr size_t CHUNK_SIZE = 16_Ki; enum class OP { READ_KEY, WRITE_KEY }; std::vector<OP> _op_stack; char _my_key; diff --git a/vespalib/src/vespa/vespalib/net/socket_address.cpp b/vespalib/src/vespa/vespalib/net/socket_address.cpp index 1a7a04b2925..dee56c78c5e 100644 --- a/vespalib/src/vespa/vespalib/net/socket_address.cpp +++ b/vespalib/src/vespa/vespalib/net/socket_address.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 "socket_address.h" +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/stringfmt.h> #include <sys/types.h> #include <sys/un.h> @@ -71,7 +72,7 @@ SocketAddress::ip_address() const vespalib::string SocketAddress::reverse_lookup() const { - std::vector<char> result(4096, '\0'); + std::vector<char> result(4_Ki, '\0'); getnameinfo(addr(), _size, &result[0], 4000, nullptr, 0, NI_NAMEREQD); return &result[0]; } diff --git a/vespalib/src/vespa/vespalib/net/tls/crypto_codec_adapter.h b/vespalib/src/vespa/vespalib/net/tls/crypto_codec_adapter.h index 4926c757bfb..a31e8c5dfed 100644 --- a/vespalib/src/vespa/vespalib/net/tls/crypto_codec_adapter.h +++ b/vespalib/src/vespa/vespalib/net/tls/crypto_codec_adapter.h @@ -5,6 +5,7 @@ #include "tls_crypto_socket.h" #include <vespa/vespalib/net/socket_handle.h> #include <vespa/vespalib/data/smart_buffer.h> +#include <vespa/vespalib/util/size_literals.h> #include "crypto_codec.h" namespace vespalib::net::tls { @@ -32,7 +33,7 @@ private: ssize_t flush_all(); // -1/0 -> error/ok public: CryptoCodecAdapter(SocketHandle socket, std::unique_ptr<CryptoCodec> codec) - : _input(64 * 1024), _output(64 * 1024), _socket(std::move(socket)), _codec(std::move(codec)), + : _input(64_Ki), _output(64_Ki), _socket(std::move(socket)), _codec(std::move(codec)), _got_tls_close(false), _encoded_tls_close(false) {} void inject_read_data(const char *buf, size_t len) override; int get_fd() const override { return _socket.get(); } diff --git a/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_socket.cpp b/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_socket.cpp index 8ab6adad2e5..d5ab1113013 100644 --- a/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_socket.cpp +++ b/vespalib/src/vespa/vespalib/net/tls/maybe_tls_crypto_socket.cpp @@ -5,6 +5,7 @@ #include "tls_crypto_socket.h" #include "protocol_snooping.h" #include <vespa/vespalib/data/smart_buffer.h> +#include <vespa/vespalib/util/size_literals.h> namespace vespalib { @@ -30,7 +31,7 @@ private: public: MyCryptoSocket(CryptoSocket::UP &self, SocketHandle socket, std::shared_ptr<AbstractTlsCryptoEngine> tls_engine) - : _self(self), _socket(std::move(socket)), _factory(std::move(tls_engine)), _buffer(4096) + : _self(self), _socket(std::move(socket)), _factory(std::move(tls_engine)), _buffer(4_Ki) { static_assert(SNOOP_SIZE == 8); } diff --git a/vespalib/src/vespa/vespalib/net/tls/protocol_snooping.cpp b/vespalib/src/vespa/vespalib/net/tls/protocol_snooping.cpp index 6ccfc7f27ac..a3661814cbf 100644 --- a/vespalib/src/vespa/vespalib/net/tls/protocol_snooping.cpp +++ b/vespalib/src/vespa/vespalib/net/tls/protocol_snooping.cpp @@ -1,5 +1,6 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "protocol_snooping.h" +#include <vespa/vespalib/util/size_literals.h> #include <iostream> #include <cstdlib> #include <stdint.h> @@ -63,14 +64,14 @@ TlsSnoopingResult snoop_client_hello_header(const char* buf) noexcept { if (!is_expected_tls_protocol_version(buf)) { return TlsSnoopingResult::ProtocolVersionMismatch; } - // Length of TLS record follows. Must be <= 16KiB + 2048 (16KiB + 256 on v1.3). + // Length of TLS record follows. Must be <= 16KiB + 2_Ki (16KiB + 256 on v1.3). // We expect that the first record contains _only_ a ClientHello with no coalescing // and no fragmentation. This is technically a violation of the TLS spec, but this // particular detection logic is only intended to be used against other Vespa nodes // where we control frame sizes and where such fragmentation should not take place. // We also do not support TLSv1.3 0-RTT which may trigger early data. uint16_t length = tls_record_length(buf); - if ((length < 4) || (length > (16384 + 2048))) { + if ((length < 4) || (length > (16_Ki + 2048))) { return TlsSnoopingResult::RecordSizeRfcViolation; } if (!is_client_hello_handshake_record(buf)) { diff --git a/vespalib/src/vespa/vespalib/portal/http_connection.cpp b/vespalib/src/vespa/vespalib/portal/http_connection.cpp index aa2c0ec4cdd..cf12ad4e8d5 100644 --- a/vespalib/src/vespa/vespalib/portal/http_connection.cpp +++ b/vespalib/src/vespa/vespalib/portal/http_connection.cpp @@ -2,13 +2,14 @@ #include "http_connection.h" #include <vespa/vespalib/data/output_writer.h> +#include <vespa/vespalib/util/size_literals.h> #include <cassert> namespace vespalib::portal { namespace { -constexpr size_t CHUNK_SIZE = 4096; +constexpr size_t CHUNK_SIZE = 4_Ki; enum class ReadRes { OK, END, FAIL }; enum class WriteRes { OK, BLOCKED, FAIL }; diff --git a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp index 8114923a9fc..61d58e6e2a9 100644 --- a/vespalib/src/vespa/vespalib/stllike/asciistream.cpp +++ b/vespalib/src/vespa/vespalib/stllike/asciistream.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/memory.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/locale/c.h> #include <vespa/fastos/file.h> #include <algorithm> @@ -614,7 +615,7 @@ asciistream asciistream::createFromDevice(stringref fileName) FastOS_File file(vespalib::string(fileName).c_str()); asciistream is; if (file.OpenReadOnly()) { - char buf[8192]; + char buf[8_Ki]; for (ssize_t actual = file.Read(buf, sizeof(buf)); actual > 0; actual = file.Read(buf, sizeof(buf))) { is << stringref(buf, actual); } diff --git a/vespalib/src/vespa/vespalib/testkit/test_hook.cpp b/vespalib/src/vespa/vespalib/testkit/test_hook.cpp index 31a6c8f4e28..afc0792e729 100644 --- a/vespalib/src/vespa/vespalib/testkit/test_hook.cpp +++ b/vespalib/src/vespa/vespalib/testkit/test_hook.cpp @@ -2,6 +2,7 @@ #include "test_hook.h" #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/size_literals.h> #include <regex> #include <vespa/fastos/thread.h> @@ -18,7 +19,7 @@ struct FastOSTestThreadRunner : FastOS_Runnable { struct FastOSTestThreadFactory : TestThreadFactory { FastOS_ThreadPool threadPool; - FastOSTestThreadFactory() : threadPool(256 * 1024) {} + FastOSTestThreadFactory() : threadPool(256_Ki) {} void createThread(TestThreadEntry &entry) override { threadPool.NewThread(new FastOSTestThreadRunner(entry), 0); } diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp index 3cd8844dd73..7dfdb005c7a 100644 --- a/vespalib/src/vespa/vespalib/util/alloc.cpp +++ b/vespalib/src/vespa/vespalib/util/alloc.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/backtrace.h> +#include <vespa/vespalib/util/size_literals.h> #include <map> #include <atomic> #include <unordered_map> @@ -233,7 +234,7 @@ createAutoAllocatorsWithDefault() { AutoAllocatorsMapWithDefault _G_availableAutoAllocators = createAutoAllocatorsWithDefault(); alloc::HeapAllocator _G_heapAllocatorDefault; alloc::AlignedHeapAllocator _G_4KalignedHeapAllocator(1024); -alloc::AlignedHeapAllocator _G_1KalignedHeapAllocator(4096); +alloc::AlignedHeapAllocator _G_1KalignedHeapAllocator(4_Ki); alloc::AlignedHeapAllocator _G_512BalignedHeapAllocator(512); alloc::MMapAllocator _G_mmapAllocatorDefault; diff --git a/vespalib/src/vespa/vespalib/util/child_process.cpp b/vespalib/src/vespa/vespalib/util/child_process.cpp index 33ea4cce9e5..9233932336f 100644 --- a/vespalib/src/vespa/vespalib/util/child_process.cpp +++ b/vespalib/src/vespa/vespalib/util/child_process.cpp @@ -3,6 +3,7 @@ #include "guard.h" #include "child_process.h" #include <cstring> +#include <vespa/vespalib/util/size_literals.h> namespace vespalib { @@ -296,7 +297,7 @@ ChildProcess::run(const std::string &input, const char *cmd, { ChildProcess proc(cmd); child_process::Timer timer(msTimeout); - char buf[4096]; + char buf[4_Ki]; proc.write(input.data(), input.length()); proc.close(); // close stdin while (!proc.eof() && !timer.timeOut()) { diff --git a/vespalib/src/vespa/vespalib/websocket/connection.cpp b/vespalib/src/vespa/vespalib/websocket/connection.cpp index 68641bd00d3..5962575ac9d 100644 --- a/vespalib/src/vespa/vespalib/websocket/connection.cpp +++ b/vespalib/src/vespa/vespalib/websocket/connection.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 "connection.h" +#include <vespa/vespalib/util/size_literals.h> #include <cstdarg> #include <cassert> @@ -52,7 +53,7 @@ bool Connection::fill_input(size_t min_bytes) { while (_input.used() < min_bytes) { - size_t max_read = (8 * 1024); + size_t max_read = (8_Ki); char *ptr = _input.reserve(max_read); ssize_t read_res = _socket->read(ptr, max_read); if (read_res > 0) { |