change to f64
parent
e7a51c07d0
commit
ec44f3d568
|
@ -54,7 +54,7 @@ pub struct Config {
|
||||||
#[serde(default = "default_sqlite_wal_clean_second_timeout")]
|
#[serde(default = "default_sqlite_wal_clean_second_timeout")]
|
||||||
sqlite_wal_clean_second_timeout: u32,
|
sqlite_wal_clean_second_timeout: u32,
|
||||||
#[serde(default = "default_sqlite_spillover_reap_fraction")]
|
#[serde(default = "default_sqlite_spillover_reap_fraction")]
|
||||||
sqlite_spillover_reap_fraction: u32,
|
sqlite_spillover_reap_fraction: f64,
|
||||||
#[serde(default = "default_sqlite_spillover_reap_interval_secs")]
|
#[serde(default = "default_sqlite_spillover_reap_interval_secs")]
|
||||||
sqlite_spillover_reap_interval_secs: u32,
|
sqlite_spillover_reap_interval_secs: u32,
|
||||||
#[serde(default = "default_max_request_size")]
|
#[serde(default = "default_max_request_size")]
|
||||||
|
@ -125,8 +125,8 @@ fn default_sqlite_wal_clean_second_timeout() -> u32 {
|
||||||
2
|
2
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_sqlite_spillover_reap_fraction() -> u32 {
|
fn default_sqlite_spillover_reap_fraction() -> f64 {
|
||||||
2
|
2.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_sqlite_spillover_reap_interval_secs() -> u32 {
|
fn default_sqlite_spillover_reap_interval_secs() -> u32 {
|
||||||
|
@ -558,9 +558,7 @@ impl Database {
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
pub async fn start_spillover_reap_task(engine: Arc<Engine>, config: &Config) {
|
pub async fn start_spillover_reap_task(engine: Arc<Engine>, config: &Config) {
|
||||||
use std::convert::TryInto;
|
let fraction_factor = config.sqlite_spillover_reap_fraction.max(1.0);
|
||||||
|
|
||||||
let fraction_factor = config.sqlite_spillover_reap_fraction.max(1).try_into().unwrap(/* We just converted it to be at least 1 */);
|
|
||||||
let interval_secs = config.sqlite_spillover_reap_interval_secs as u64;
|
let interval_secs = config.sqlite_spillover_reap_interval_secs as u64;
|
||||||
|
|
||||||
let weak = Arc::downgrade(&engine);
|
let weak = Arc::downgrade(&engine);
|
||||||
|
|
|
@ -9,7 +9,6 @@ use rusqlite::{params, Connection, DatabaseName::Main, OptionalExtension};
|
||||||
use std::{
|
use std::{
|
||||||
collections::BTreeMap,
|
collections::BTreeMap,
|
||||||
future::Future,
|
future::Future,
|
||||||
num::NonZeroU32,
|
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
@ -246,10 +245,13 @@ impl Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reaps (at most) (.len() / `fraction`) (rounded down, min 1) connections.
|
// Reaps (at most) (.len() / `fraction`) (rounded down, min 1) connections.
|
||||||
pub fn reap_spillover_by_fraction(&self, fraction: NonZeroU32) {
|
pub fn reap_spillover_by_fraction(&self, fraction: f64) {
|
||||||
let mut reaped = 0;
|
let mut reaped = 0;
|
||||||
|
|
||||||
let amount = ((self.pool.spills.1.len() as u32) / fraction).max(1);
|
let spill_amount = self.pool.spills.1.len() as f64;
|
||||||
|
let fraction = fraction.max(1.0 /* Can never be too sure */);
|
||||||
|
|
||||||
|
let amount = (spill_amount / fraction).max(1.0) as u32;
|
||||||
|
|
||||||
for _ in 0..amount {
|
for _ in 0..amount {
|
||||||
if self.pool.spills.try_take().is_some() {
|
if self.pool.spills.try_take().is_some() {
|
||||||
|
|
Loading…
Reference in New Issue