Commit 400c9045 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

imp linux get_max_process_size. addresses #1387

git-svn-id: file:///svn/toku/tokudb@8745 c7de825b-a66e-492c-adef-691d508d4ae1
parent afdb6c6b
...@@ -169,3 +169,19 @@ toku_os_is_absolute_name(const char* path) { ...@@ -169,3 +169,19 @@ toku_os_is_absolute_name(const char* path) {
return path[0] == '/'; return path[0] == '/';
} }
int
toku_os_get_max_process_data_size(uint64_t *maxdata) {
int r;
struct rlimit rlimit;
r = getrlimit(RLIMIT_DATA, &rlimit);
if (r == 0) {
*maxdata = rlimit.rlim_max;
// for 32 bit processes, we assume that 1/2 of the address space is
// used for mapping the kernel.
if (sizeof (rlimit.rlim_max) == 4 && rlimit.rlim_max == 0xffffffff)
*maxdata /= 2;
} else
r = errno;
return r;
}
CPPFLAGS = -I../../include -I.. CPPFLAGS = -I../../toku_include -I..
CFLAGS = -Wall -Werror -g -O0 CFLAGS = -Wall -Werror -g -O0
LDFLAGS = ../libtokuportability.a -lpthread LDFLAGS = ../libtokuportability.a -lpthread
SRCS = $(wildcard test-*.c) SRCS = $(wildcard test-*.c)
......
#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <unistd.h>
#include <assert.h>
#include "toku_os.h"
int main(void) {
uint64_t maxdata;
int r = toku_os_get_max_process_data_size(&maxdata);
assert(r == 0);
printf("maxdata=%"PRIu64"\n", maxdata);
return 0;
}
...@@ -19,10 +19,10 @@ int toku_os_get_number_processors(void); ...@@ -19,10 +19,10 @@ int toku_os_get_number_processors(void);
// Returns: the number of active processors in the system // Returns: the number of active processors in the system
int toku_os_get_number_active_processors(void); int toku_os_get_number_active_processors(void);
// Returns: the system page size // Returns: the system page size (in bytes)
int toku_os_get_pagesize(void); int toku_os_get_pagesize(void);
// Returns: the total number of bytes of physical memory // Returns: the size of physical memory (in bytes)
uint64_t toku_os_get_phys_memory_size(void); uint64_t toku_os_get_phys_memory_size(void);
// Returns: 0 on success // Returns: 0 on success
...@@ -51,6 +51,11 @@ int toku_os_get_rss(int64_t *rss); ...@@ -51,6 +51,11 @@ int toku_os_get_rss(int64_t *rss);
// Get the maximum in memory size (in bytes) of the current process // Get the maximum in memory size (in bytes) of the current process
int toku_os_get_max_rss(int64_t *maxrss); int toku_os_get_max_rss(int64_t *maxrss);
// Get the maximum size of the process data size (in bytes)
// Success: returns 0 and sets *maxdata to the data size
// Fail: returns an error number
int toku_os_get_max_process_data_size(uint64_t *maxdata);
int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("default"))); int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("default")));
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment