Set geometry to something more reasonable
This commit is contained in:
parent
c303d85aaf
commit
83e55773b2
@ -3,7 +3,8 @@ use crate::database::wrapped::WrappedTable;
|
|||||||
use crate::wrapper::{ByteWrapper, ZeroCopyByteWrapper};
|
use crate::wrapper::{ByteWrapper, ZeroCopyByteWrapper};
|
||||||
use anyhow::{ensure, Context};
|
use anyhow::{ensure, Context};
|
||||||
use libmdbx::{
|
use libmdbx::{
|
||||||
DatabaseFlags, Environment, EnvironmentFlags, Transaction, TransactionKind, WriteMap, RO, RW,
|
DatabaseFlags, Environment, EnvironmentFlags, Geometry, Transaction, TransactionKind, WriteMap,
|
||||||
|
RO, RW,
|
||||||
};
|
};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -18,8 +19,21 @@ impl Env {
|
|||||||
let mut flags = EnvironmentFlags::default();
|
let mut flags = EnvironmentFlags::default();
|
||||||
flags.no_sub_dir = true;
|
flags.no_sub_dir = true;
|
||||||
|
|
||||||
|
// TODO make the geometry more configurable.
|
||||||
|
let mut geom = Geometry::default();
|
||||||
|
// Don't stop the database growing until it hits 64 GiB.
|
||||||
|
// (The default is 1 MiB which is just not enough!)
|
||||||
|
geom.size = Some(1024 * 1024..64 * 1024 * 1024 * 1024);
|
||||||
|
|
||||||
|
// Grow 4 MiB at a time.
|
||||||
|
geom.growth_step = Some(4 * 1024 * 1024);
|
||||||
|
// Shrink 16 MiB at a time.
|
||||||
|
geom.shrink_threshold = Some(16 * 1024 * 1024);
|
||||||
|
// (Yes these numbers represent a large database).
|
||||||
|
|
||||||
let environment = Environment::new()
|
let environment = Environment::new()
|
||||||
.set_max_dbs(256)
|
.set_max_dbs(256)
|
||||||
|
.set_geometry(geom)
|
||||||
.set_flags(flags)
|
.set_flags(flags)
|
||||||
.open(path)?;
|
.open(path)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user