mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 10:48:18 -07:00
change to f64
This commit is contained in:
parent
e7a51c07d0
commit
ec44f3d568
@ -54,7 +54,7 @@ pub struct Config {
|
||||
#[serde(default = "default_sqlite_wal_clean_second_timeout")]
|
||||
sqlite_wal_clean_second_timeout: u32,
|
||||
#[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")]
|
||||
sqlite_spillover_reap_interval_secs: u32,
|
||||
#[serde(default = "default_max_request_size")]
|
||||
@ -125,8 +125,8 @@ fn default_sqlite_wal_clean_second_timeout() -> u32 {
|
||||
2
|
||||
}
|
||||
|
||||
fn default_sqlite_spillover_reap_fraction() -> u32 {
|
||||
2
|
||||
fn default_sqlite_spillover_reap_fraction() -> f64 {
|
||||
2.0
|
||||
}
|
||||
|
||||
fn default_sqlite_spillover_reap_interval_secs() -> u32 {
|
||||
@ -558,9 +558,7 @@ impl Database {
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
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).try_into().unwrap(/* We just converted it to be at least 1 */);
|
||||
let fraction_factor = config.sqlite_spillover_reap_fraction.max(1.0);
|
||||
let interval_secs = config.sqlite_spillover_reap_interval_secs as u64;
|
||||
|
||||
let weak = Arc::downgrade(&engine);
|
||||
|
@ -9,7 +9,6 @@ use rusqlite::{params, Connection, DatabaseName::Main, OptionalExtension};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
future::Future,
|
||||
num::NonZeroU32,
|
||||
ops::Deref,
|
||||
path::{Path, PathBuf},
|
||||
pin::Pin,
|
||||
@ -246,10 +245,13 @@ impl Engine {
|
||||
}
|
||||
|
||||
// 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 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 {
|
||||
if self.pool.spills.try_take().is_some() {
|
||||
|
Loading…
Reference in New Issue
Block a user