preliminary use of the config system for some settings
* backend.filehandles maximum filehandles used * backend.mmap_window_size mapping window start size * backend.as_limit address space limit This needs to be changed to use the lumieraorg_configuration interface.
This commit is contained in:
parent
2a0b5dca5e
commit
5bbe80b370
3 changed files with 75 additions and 25 deletions
|
|
@ -78,3 +78,32 @@ Sensible defaults are initialized at installation time.
|
|||
|
||||
plugin.path
|
||||
|
||||
|
||||
I/O Backend
|
||||
-----------
|
||||
|
||||
File handling
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
How many filehandles the backend shall use [approx 2/3 of all available]
|
||||
|
||||
backend.filehandles
|
||||
|
||||
|
||||
|
||||
Memory mapped Files
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Address space limit (memory mapping)
|
||||
Defaults:
|
||||
3GiB on 32 bit arch
|
||||
192TiB on 64 bit arch
|
||||
|
||||
backend.as_limit
|
||||
|
||||
Default start size for mmaping windows.
|
||||
128MB on 32 bit arch
|
||||
2GB on 64 bit arch
|
||||
|
||||
backend.mmap_window_size
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "lib/safeclib.h"
|
||||
|
||||
#include "backend/backend.h"
|
||||
#include "backend/config.h"
|
||||
#include "backend/filehandlecache.h"
|
||||
#include "backend/filedescriptor.h"
|
||||
#include "backend/mmapcache.h"
|
||||
|
|
@ -56,30 +59,38 @@ lumiera_backend_init (void)
|
|||
|
||||
TODO ("add config options to override following defaults");
|
||||
|
||||
/* roughly 2/3 of all availables filehandles are managed by the backend */
|
||||
int max_entries = (sysconf (_SC_OPEN_MAX)-10)*2/3;
|
||||
INFO (backend, "using %d filehandles", max_entries);
|
||||
|
||||
const char* filehandles = lumiera_tmpbuf_snprintf (SIZE_MAX,
|
||||
"backend.filehandles = %d",
|
||||
/* roughly 2/3 of all availables filehandles are managed by the backend */
|
||||
(sysconf (_SC_OPEN_MAX)-10)*2/3);
|
||||
|
||||
lumiera_config_setdefault (filehandles);
|
||||
|
||||
long long max_entries;
|
||||
lumiera_config_number_get ("backend.filehandles", &max_entries);
|
||||
lumiera_filehandlecache_new (max_entries);
|
||||
|
||||
struct rlimit as_limit;
|
||||
getrlimit (RLIMIT_AS, &as_limit);
|
||||
|
||||
if (as_limit.rlim_cur == RLIM_INFINITY)
|
||||
{
|
||||
#if SIZE_MAX <= 4294967295UL
|
||||
INFO (backend, "address space not limited, backend will mmap at most 1.5GiB");
|
||||
as_limit.rlim_cur = 1610612736U;
|
||||
lumiera_config_setdefault ("backend.as_limit = 3221225469");
|
||||
#else
|
||||
INFO (backend, "address space not limited, backend will mmap at most 192TiB");
|
||||
as_limit.rlim_cur = 211106232532992U;
|
||||
lumiera_config_setdefault ("backend.as_limit = 211106232532992");
|
||||
#endif
|
||||
|
||||
struct rlimit as_rlimit;
|
||||
getrlimit (RLIMIT_AS, &as_rlimit);
|
||||
|
||||
long long as_limit = (long long)as_rlimit.rlim_cur;
|
||||
if (as_rlimit.rlim_cur == RLIM_INFINITY)
|
||||
{
|
||||
lumiera_config_number_get ("backend.as_limit", &as_limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO (backend, "address space limited to %luMiB", as_limit.rlim_cur/1024/1024);
|
||||
INFO (backend, "address space limited to %luMiB", as_rlimit.rlim_cur/1024/1024);
|
||||
}
|
||||
|
||||
lumiera_mmapcache_new (as_limit.rlim_cur);
|
||||
lumiera_mmapcache_new (as_limit);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "backend/mmap.h"
|
||||
#include "backend/mmapcache.h"
|
||||
#include "backend/config.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
|
@ -46,16 +47,6 @@ LUMIERA_ERROR_DEFINE (MMAP_SPACE, "Address space exhausted");
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* default size for the mmaping window
|
||||
* 128MB on 32 bit arch
|
||||
* 2GB on 64 bit arch
|
||||
*/
|
||||
#if SIZE_MAX <= 4294967295U
|
||||
static size_t mmap_window_size = 134217728UL;
|
||||
#else
|
||||
static size_t mmap_window_size = 2147483648UL;
|
||||
#endif
|
||||
|
||||
LumieraMMap
|
||||
lumiera_mmap_init (LumieraMMap self, LumieraFile file, LList acquirer, off_t start, size_t size, size_t chunksize)
|
||||
|
|
@ -69,6 +60,25 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, LList acquirer, off_t sta
|
|||
REQUIRE (start >= 0);
|
||||
REQUIRE (size);
|
||||
|
||||
static int once = 0;
|
||||
if (!once)
|
||||
{
|
||||
once = 1;
|
||||
/**
|
||||
* default size for the mmaping window
|
||||
* 128MB on 32 bit arch
|
||||
* 2GB on 64 bit arch
|
||||
*/
|
||||
#if SIZE_MAX <= 4294967295U
|
||||
lumiera_config_setdefault ("backend.mmap_window_size = 134217728");
|
||||
#else
|
||||
lumiera_config_setdefault ("backend.mmap_window_size = 2147483648");
|
||||
#endif
|
||||
}
|
||||
|
||||
long long mmap_window_size = 0;
|
||||
lumiera_config_number_get ("backend.mmap_window_size", &mmap_window_size);
|
||||
|
||||
LumieraFiledescriptor descriptor = file->descriptor;
|
||||
|
||||
int fd = lumiera_file_handle_acquire (file);
|
||||
|
|
@ -139,7 +149,7 @@ lumiera_mmap_init (LumieraMMap self, LumieraFile file, LList acquirer, off_t sta
|
|||
goto ewrite;
|
||||
}
|
||||
}
|
||||
else if (length < mmap_window_size)
|
||||
else if (length < (size_t)mmap_window_size)
|
||||
length = mmap_window_size;
|
||||
|
||||
if ((descriptor->flags & O_ACCMODE) == O_RDONLY)
|
||||
|
|
|
|||
Loading…
Reference in a new issue