mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Unified usages of getPageSize
1. Introduced getPageSize function. 2. Replaced usages of getpagesize with getPageSize function. 3. Replaced usages of sysconf(_SG_PAGESIZE) with getPageSize function.
This commit is contained in:
parent
058fbd5222
commit
dbb2fbcdd5
@ -86,6 +86,7 @@ private:
|
||||
|
||||
static size_t roundUpToPageSize(size_t s)
|
||||
{
|
||||
/// TODO: Consider to fix, better to store ::getPageSize in Arena instance
|
||||
return (s + 4096 - 1) / 4096 * 4096;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/StringUtils/StringUtils.h>
|
||||
#include <Common/UTF8Helpers.h>
|
||||
#include <Common/getPageSize.h>
|
||||
#include <Core/Defines.h>
|
||||
#include <ext/range.h>
|
||||
#include <Poco/Unicode.h>
|
||||
@ -37,7 +38,7 @@ struct StringSearcherBase
|
||||
{
|
||||
#ifdef __SSE2__
|
||||
static constexpr auto n = sizeof(__m128i);
|
||||
const int page_size = getpagesize();
|
||||
const int page_size = ::getPageSize();
|
||||
|
||||
bool pageSafe(const void * const ptr) const
|
||||
{
|
||||
|
7
src/Common/getPageSize.cpp
Normal file
7
src/Common/getPageSize.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "getPageSize.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
long getPageSize() {
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
}
|
4
src/Common/getPageSize.h
Normal file
4
src/Common/getPageSize.h
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
/// Get memory page size
|
||||
long getPageSize();
|
@ -99,6 +99,7 @@ SRCS(
|
||||
getMappedArea.cpp
|
||||
getMultipleKeysFromConfig.cpp
|
||||
getNumberOfPhysicalCPUCores.cpp
|
||||
getPageSize.cpp
|
||||
hasLinuxCapability.cpp
|
||||
hex.cpp
|
||||
isLocalAddress.cpp
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <Common/ProfileEvents.h>
|
||||
#include <Common/formatReadable.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/getPageSize.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <IO/MMapReadBufferFromFileDescriptor.h>
|
||||
|
||||
@ -39,7 +40,7 @@ void MMapReadBufferFromFileDescriptor::init(int fd_, size_t offset, size_t lengt
|
||||
|
||||
BufferBase::set(static_cast<char *>(buf), length, 0);
|
||||
|
||||
int page_size = ::getpagesize();
|
||||
int page_size = ::getPageSize();
|
||||
ReadBuffer::padded = (length % page_size) > 0 && (length % page_size) <= (page_size - 15);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <Common/Stopwatch.h>
|
||||
#include <Common/ThreadPool.h>
|
||||
#include <Common/randomSeed.h>
|
||||
#include <Common/getPageSize.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
@ -46,7 +47,7 @@ void thread(int fd, int mode, size_t min_offset, size_t max_offset, size_t block
|
||||
{
|
||||
using namespace DB;
|
||||
|
||||
Memory<> direct_buf(block_size, sysconf(_SC_PAGESIZE));
|
||||
Memory<> direct_buf(block_size, ::getPageSize());
|
||||
std::vector<char> simple_buf(block_size);
|
||||
|
||||
char * buf;
|
||||
|
@ -14,6 +14,7 @@ int main(int, char **) { return 0; }
|
||||
#include <Common/ThreadPool.h>
|
||||
#include <Common/Stopwatch.h>
|
||||
#include <Common/randomSeed.h>
|
||||
#include <Common/getPageSize.h>
|
||||
#include <pcg_random.hpp>
|
||||
#include <IO/BufferWithOwnMemory.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
@ -52,7 +53,7 @@ void thread(int fd, int mode, size_t min_offset, size_t max_offset, size_t block
|
||||
|
||||
std::vector<Memory<>> buffers(buffers_count);
|
||||
for (size_t i = 0; i < buffers_count; ++i)
|
||||
buffers[i] = Memory<>(block_size, sysconf(_SC_PAGESIZE));
|
||||
buffers[i] = Memory<>(block_size, ::getPageSize());
|
||||
|
||||
pcg64_fast rng(randomSeed());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user