Skip to content

Commit

Permalink
lmdb: fix compilation on 32-bit arch
Browse files Browse the repository at this point in the history
Reduce map size to 4GB for 32-bit machines.

Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
  • Loading branch information
yukibtc committed Sep 19, 2024
1 parent 79ecb35 commit 487d797
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/nostr-lmdb/src/store/lmdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,20 @@ impl Lmdb {
where
P: AsRef<Path>,
{
// 64-bit
#[cfg(target_pointer_width = "64")]
let map_size: usize = 1024 * 1024 * 1024 * 32; // 32 GB

// 32-bit
#[cfg(target_pointer_width = "32")]
let map_size: usize = u32::MAX as usize; // 4 GB

// Construct LMDB env
let env: Env = unsafe {
EnvOpenOptions::new()
.flags(EnvFlags::NO_TLS)
.max_dbs(9)
.map_size(1048576 * 1024 * 24) // 24 GB
.map_size(map_size)
.open(path)?
};

Expand Down

0 comments on commit 487d797

Please sign in to comment.