From: Mathieu Parent Date: Wed, 3 Oct 2018 05:18:08 +0000 Subject: [PATCH] Reduce the LMDB size to 256MB on 32-bit https://bugzilla.samba.org/show_bug.cgi?id=13630 Signed-off-by: Mathieu Parent --- ldb_mdb/ldb_mdb.c | 8 +++++++- wscript | 43 ++++++++++++++----------------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/ldb_mdb/ldb_mdb.c b/ldb_mdb/ldb_mdb.c index af552fe..388e423 100644 --- a/ldb_mdb/ldb_mdb.c +++ b/ldb_mdb/ldb_mdb.c @@ -678,7 +678,13 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx, unsigned int flags) { int ret; +#if __SIZE_WIDTH__ == 64 const size_t mmap_size = 8LL * GIGABYTE; +#elif __SIZE_WIDTH__ == 32 + const size_t mmap_size = 256 * 1024*1024; +#else +#error Unsupported __SIZE_WIDTH__ +#endif unsigned int mdb_flags = MDB_NOSUBDIR|MDB_NOTLS; /* * MDB_NOSUBDIR implies there is a separate file called path and a @@ -724,7 +730,7 @@ static int lmdb_open_env(TALLOC_CTX *mem_ctx, } /* - * Currently we set a 8Gb maximum database size + * Currently we set a 8Gb (256MB on 32-bit) maximum database size * via the constant mmap_size above */ ret = mdb_env_set_mapsize(*env, mmap_size); diff --git a/wscript b/wscript index 1ea0fd9..d327103 100644 --- a/wscript +++ b/wscript @@ -110,39 +110,24 @@ def configure(conf): implied_deps='replace talloc tdb tevent'): conf.define('USING_SYSTEM_LDB', 1) - if not conf.CHECK_CODE('return !(sizeof(size_t) >= 8)', - "HAVE_64_BIT_SIZE_T_FOR_LMDB", - execute=True, - msg='Checking for a 64-bit host to ' - 'support lmdb'): - Logs.warn("--without-ldb-lmdb implied as this " - "host is not 64-bit") - - if not conf.env.standalone_ldb and \ - not Options.options.without_ad_dc and \ - conf.CONFIG_GET('ENABLE_SELFTEST'): - Logs.warn("NOTE: Some AD DC parts of selftest will fail") - + if conf.env.standalone_ldb: + if Options.options.without_ldb_lmdb: + conf.env.REQUIRE_LMDB = False + else: + conf.env.REQUIRE_LMDB = True + elif Options.options.without_ad_dc: conf.env.REQUIRE_LMDB = False else: - if conf.env.standalone_ldb: - if Options.options.without_ldb_lmdb: - conf.env.REQUIRE_LMDB = False - else: - conf.env.REQUIRE_LMDB = True - elif Options.options.without_ad_dc: + if Options.options.without_ldb_lmdb: + if not Options.options.without_ad_dc and \ + conf.CONFIG_GET('ENABLE_SELFTEST'): + raise Utils.WafError('--without-ldb-lmdb conflicts ' + 'with --enable-selftest while ' + 'building the AD DC') + conf.env.REQUIRE_LMDB = False else: - if Options.options.without_ldb_lmdb: - if not Options.options.without_ad_dc and \ - conf.CONFIG_GET('ENABLE_SELFTEST'): - raise Utils.WafError('--without-ldb-lmdb conflicts ' - 'with --enable-selftest while ' - 'building the AD DC') - - conf.env.REQUIRE_LMDB = False - else: - conf.env.REQUIRE_LMDB = True + conf.env.REQUIRE_LMDB = True if conf.CONFIG_SET('USING_SYSTEM_LDB'): -- 2.19.0