FreeBSD Bugzilla – Attachment 217832 Details for
Bug 249205
databases/clickhouse: apply patch from #13859: MemoryTracking support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
databases/clickhouse: apply patch from #13859: MemoryTracking support
clickhouse.txt (text/plain), 7.63 KB, created by
Oleg Ginzburg
on 2020-09-09 08:03:02 UTC
(
hide
)
Description:
databases/clickhouse: apply patch from #13859: MemoryTracking support
Filename:
MIME Type:
Creator:
Oleg Ginzburg
Created:
2020-09-09 08:03:02 UTC
Size:
7.63 KB
patch
obsolete
>diff -ruN clickhouse.bak/Makefile clickhouse/Makefile >--- clickhouse.bak/Makefile 2020-09-06 18:37:37.963400000 +0300 >+++ clickhouse/Makefile 2020-09-09 10:55:00.422045000 +0300 >@@ -5,6 +5,7 @@ > PORTVERSION= 20.7.2.30 > DISTVERSIONPREFIX= v > DISTVERSIONSUFFIX= -stable >+PORTREVISION= 1 > CATEGORIES= databases > > MAINTAINER= olevole@olevole.ru >diff -ruN clickhouse.bak/files/patch-cmake_freebsd_default__libs.cmake clickhouse/files/patch-cmake_freebsd_default__libs.cmake >--- clickhouse.bak/files/patch-cmake_freebsd_default__libs.cmake 1970-01-01 03:00:00.000000000 +0300 >+++ clickhouse/files/patch-cmake_freebsd_default__libs.cmake 2020-09-09 10:50:45.665491000 +0300 >@@ -0,0 +1,22 @@ >+--- cmake/freebsd/default_libs.cmake.orig 2020-08-31 16:22:57 UTC >++++ cmake/freebsd/default_libs.cmake >+@@ -4,13 +4,13 @@ if (NOT COMPILER_CLANG) >+ message (FATAL_ERROR "FreeBSD build is supported only for Clang") >+ endif () >+ >+-if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64") >+- execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-x86_64.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) >+-else () >+- execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-${CMAKE_SYSTEM_PROCESSOR}.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) >+-endif () >++#if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64") >++# execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-x86_64.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) >++#else () >++# execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-${CMAKE_SYSTEM_PROCESSOR}.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) >++#endif () >+ >+-set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -lrt -lpthread") >++set (DEFAULT_LIBS "${DEFAULT_LIBS} ${BUILTINS_LIBRARY} ${COVERAGE_OPTION} -lc -lm -lrt -lpthread -lcompiler_rt -lprocstat") >+ >+ message(STATUS "Default libraries: ${DEFAULT_LIBS}") >+ >diff -ruN clickhouse.bak/files/patch-src_Common_MemoryStatisticsOS.cpp clickhouse/files/patch-src_Common_MemoryStatisticsOS.cpp >--- clickhouse.bak/files/patch-src_Common_MemoryStatisticsOS.cpp 1970-01-01 03:00:00.000000000 +0300 >+++ clickhouse/files/patch-src_Common_MemoryStatisticsOS.cpp 2020-09-09 10:50:45.665809000 +0300 >@@ -0,0 +1,127 @@ >+--- src/Common/MemoryStatisticsOS.cpp.orig 2020-08-31 16:22:57 UTC >++++ src/Common/MemoryStatisticsOS.cpp >+@@ -1,7 +1,13 @@ >+-#if defined(OS_LINUX) >+- >+ #include <sys/types.h> >+ #include <sys/stat.h> >++ >++#ifdef OS_FREEBSD >++#include <sys/param.h> >++#include <sys/sysctl.h> >++#include <sys/user.h> >++#include <libprocstat.h> >++#endif >++ >+ #include <fcntl.h> >+ #include <unistd.h> >+ #include <cassert> >+@@ -11,9 +17,10 @@ >+ #include <Common/Exception.h> >+ #include <IO/ReadBufferFromMemory.h> >+ #include <IO/ReadHelpers.h> >+-#include <common/logger_useful.h> >+ >+ >++ >++ >+ namespace DB >+ { >+ >+@@ -23,21 +30,40 @@ namespace ErrorCodes >+ extern const int CANNOT_OPEN_FILE; >+ extern const int CANNOT_READ_FROM_FILE_DESCRIPTOR; >+ extern const int CANNOT_CLOSE_FILE; >++#ifdef OS_FREEBSD >++ extern const int CANNOT_ALLOCATE_MEMORY; >++#endif >+ } >+ >++#ifndef OS_FREEBSD >+ static constexpr auto filename = "/proc/self/statm"; >+ static constexpr size_t PAGE_SIZE = 4096; >++#endif >+ >+ MemoryStatisticsOS::MemoryStatisticsOS() >+ { >++#ifdef OS_FREEBSD >++ pstat = ::procstat_open_sysctl(); >++ if (NULL == pstat) >++ { >++ throwFromErrno("Cannot open sysctl", ErrorCodes::CANNOT_ALLOCATE_MEMORY); >++ } >++#else >+ fd = ::open(filename, O_RDONLY | O_CLOEXEC); >+ >+ if (-1 == fd) >+ throwFromErrno("Cannot open file " + std::string(filename), errno == ENOENT ? ErrorCodes::FILE_DOESNT_EXIST : ErrorCodes::CANNOT_OPEN_FILE); >++#endif >+ } >+ >+ MemoryStatisticsOS::~MemoryStatisticsOS() >+ { >++#ifdef OS_FREEBSD >++ if (NULL != pstat) >++ { >++ ::procstat_close(pstat); >++ } >++#else >+ if (0 != ::close(fd)) >+ { >+ try >+@@ -51,12 +77,43 @@ MemoryStatisticsOS::~MemoryStatisticsOS() >+ DB::tryLogCurrentException(__PRETTY_FUNCTION__); >+ } >+ } >++#endif >+ } >+ >+ MemoryStatisticsOS::Data MemoryStatisticsOS::get() const >+ { >+ Data data; >+ >++#ifdef OS_FREEBSD >++ size_t pagesize = ::getpagesize(); >++ unsigned int count = 0; >++ >++ struct kinfo_proc *kp; >++ struct kinfo_vmentry *kve; >++ >++ kp = ::procstat_getprocs(pstat, KERN_PROC_PID, ::getpid(), &count); >++ if (NULL == kp) >++ { >++ throwFromErrno("Cannot get proc info", ErrorCodes::CANNOT_ALLOCATE_MEMORY); >++ } >++ >++ kve = ::procstat_getvmmap(pstat, kp, &count); >++ if (NULL == kve) >++ { >++ ::procstat_freeprocs(pstat, kp); >++ throwFromErrno("Cannot get vmmap info", ErrorCodes::CANNOT_ALLOCATE_MEMORY); >++ } >++ >++ data.virt = kp->ki_size; >++ data.resident = kp->ki_rssize * pagesize; >++ data.shared = (kp->ki_rssize - kve->kve_private_resident) * pagesize; >++ data.code = kp->ki_tsize * pagesize; >++ data.data_and_stack = (kp->ki_dsize + kp->ki_ssize) * pagesize; >++ >++ ::procstat_freevmmap(pstat, kve); >++ ::procstat_freeprocs(pstat, kp); >++#else >++ >+ constexpr size_t buf_size = 1024; >+ char buf[buf_size]; >+ >+@@ -98,10 +155,8 @@ MemoryStatisticsOS::Data MemoryStatisticsOS::get() con >+ data.shared *= PAGE_SIZE; >+ data.code *= PAGE_SIZE; >+ data.data_and_stack *= PAGE_SIZE; >+- >++#endif >+ return data; >+ } >+ >+ } >+- >+-#endif >diff -ruN clickhouse.bak/files/patch-src_Common_MemoryStatisticsOS.h clickhouse/files/patch-src_Common_MemoryStatisticsOS.h >--- clickhouse.bak/files/patch-src_Common_MemoryStatisticsOS.h 1970-01-01 03:00:00.000000000 +0300 >+++ clickhouse/files/patch-src_Common_MemoryStatisticsOS.h 2020-09-09 10:50:45.666072000 +0300 >@@ -0,0 +1,22 @@ >+--- src/Common/MemoryStatisticsOS.h.orig 2020-08-31 16:22:57 UTC >++++ src/Common/MemoryStatisticsOS.h >+@@ -1,5 +1,4 @@ >+ #pragma once >+-#if defined(OS_LINUX) >+ #include <cstdint> >+ >+ >+@@ -35,9 +34,12 @@ class MemoryStatisticsOS (public) >+ Data get() const; >+ >+ private: >++#ifdef OS_FREEBSD >++ struct procstat * pstat; >++#else >+ int fd; >++#endif >+ }; >+ >+ } >+ >+-#endif >diff -ruN clickhouse.bak/files/patch-src_Interpreters_AsynchronousMetrics.cpp clickhouse/files/patch-src_Interpreters_AsynchronousMetrics.cpp >--- clickhouse.bak/files/patch-src_Interpreters_AsynchronousMetrics.cpp 1970-01-01 03:00:00.000000000 +0300 >+++ clickhouse/files/patch-src_Interpreters_AsynchronousMetrics.cpp 2020-09-09 10:50:45.666338000 +0300 >@@ -0,0 +1,11 @@ >+--- src/Interpreters/AsynchronousMetrics.cpp.orig 2020-08-31 16:22:57 UTC >++++ src/Interpreters/AsynchronousMetrics.cpp >+@@ -194,7 +194,7 @@ void AsynchronousMetrics::update() >+ new_values["Uptime"] = context.getUptimeSeconds(); >+ >+ /// Process memory usage according to OS >+-#if defined(OS_LINUX) >++#if defined(OS_LINUX) || defined(OS_FREEBSD) >+ { >+ MemoryStatisticsOS::Data data = memory_stat.get(); >+ >diff -ruN clickhouse.bak/files/patch-src_Interpreters_AsynchronousMetrics.h clickhouse/files/patch-src_Interpreters_AsynchronousMetrics.h >--- clickhouse.bak/files/patch-src_Interpreters_AsynchronousMetrics.h 1970-01-01 03:00:00.000000000 +0300 >+++ clickhouse/files/patch-src_Interpreters_AsynchronousMetrics.h 2020-09-09 10:50:45.666589000 +0300 >@@ -0,0 +1,11 @@ >+--- src/Interpreters/AsynchronousMetrics.h.orig 2020-08-31 16:22:57 UTC >++++ src/Interpreters/AsynchronousMetrics.h >+@@ -50,7 +50,7 @@ class AsynchronousMetrics (private) >+ bool quit {false}; >+ AsynchronousMetricValues values; >+ >+-#if defined(OS_LINUX) >++#if defined(OS_LINUX) || defined(OS_FREEBSD) >+ MemoryStatisticsOS memory_stat; >+ #endif >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
olevole
:
maintainer-approval+
Actions:
View
Attachments on
bug 249205
: 217832