From 12e04b45afea459a3dca841a7504ede5d1df8200 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Thu, 10 Mar 2016 14:22:30 +0100 Subject: [PATCH] Made the default page size a compile flag --- CMakeLists.txt | 3 +++ lib/defines.h | 7 ++++++- src/io.cpp | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 478f1bfb..9a214c5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,9 @@ endif() if (DEFINED BIGMETA ) add_definitions(-DBIGMETA=1) endif() +if (DEFINED DATASIZE ) + add_definitions(-DSHM_DATASIZE=${DATASIZE}) +endif() if (NOT DEFINED NOUPDATE ) add_definitions(-DUPDATER=1) endif() diff --git a/lib/defines.h b/lib/defines.h index 6322dccc..0c561630 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -57,11 +57,16 @@ static const char * DBG_LVL_LIST[] = {"NONE", "FAIL", "ERROR", "WARN", "INFO", " #endif + +#ifndef SHM_DATASIZE +#define SHM_DATASIZE 25 +#endif + /// The size used for stream header pages under Windows, where they cannot be size-detected. #define DEFAULT_META_PAGE_SIZE 16 * 1024 * 1024 /// The size used for stream data pages under Windows, where they cannot be size-detected. -#define DEFAULT_DATA_PAGE_SIZE 25 * 1024 * 1024 +#define DEFAULT_DATA_PAGE_SIZE SHM_DATASIZE * 1024 * 1024 /// The size used for server configuration pages. #define DEFAULT_CONF_PAGE_SIZE 4 * 1024 * 1024 diff --git a/src/io.cpp b/src/io.cpp index 078f5120..19c1cc24 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -490,17 +490,17 @@ namespace Mist { //If there is no page, create it if (!pagesByTrack.count(tid) || pagesByTrack[tid].size() == 0) { nextPageNum = 1; - pagesByTrack[tid][1].dataSize = (25 * 1024 * 1024);//Initialize op 25mb + pagesByTrack[tid][1].dataSize = DEFAULT_DATA_PAGE_SIZE;//Initialize op 25mb pagesByTrack[tid][1].pageNum = 1; } //Take the last allocated page std::map::reverse_iterator tmpIt = pagesByTrack[tid].rbegin(); //Compare on 8 mb boundary - if (tmpIt->second.curOffset > (8 * 1024 * 1024)) { + if (tmpIt->second.curOffset > FLIP_DATA_PAGE_SIZE) { //Create the book keeping data for the new page nextPageNum = tmpIt->second.pageNum + tmpIt->second.keyNum; INFO_MSG("We should go to next page now, transition from %lu to %d", tmpIt->second.pageNum, nextPageNum); - pagesByTrack[tid][nextPageNum].dataSize = (25 * 1024 * 1024); + pagesByTrack[tid][nextPageNum].dataSize = DEFAULT_DATA_PAGE_SIZE; pagesByTrack[tid][nextPageNum].pageNum = nextPageNum; } pagesByTrack[tid].rbegin()->second.lastKeyTime = packet.getTime();