Skip to content

Commit

Permalink
Update rusqlite, increase uncomplete buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Dec 8, 2024
1 parent b8aa331 commit 24acc12
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lazy_static = "1.0"
mime = "0.3.1"
minifier = { version = "0.3", features = ["html"] }
r2d2 = "0.8.2"
rusqlite = { version = "0.29.0", features = ["chrono", "functions", "bundled"] }
rusqlite = { version = "0.32.1", features = ["chrono", "functions", "bundled"] }
rand = "0.8"
regex = "1.0"
reqwest = { version = "0.11", features = ["blocking", "json"] }
Expand Down
5 changes: 5 additions & 0 deletions src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ impl r2d2::ManageConnection for SqliteConnectionManager {
.pragma_update(None, "foreign_keys", "ON")
.unwrap();

// increase the in-memory cache from 2MB to 50MB
connection
.pragma_update(None, "cache_size", "-51200")
.unwrap();

// per docs, this is recommended for relatively long-lived connections (like what we have
// due to the r2d2 pooling)
// https://www.sqlite.org/pragma.html#pragma_optimize
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ fn endpoint_next_crate_inner(
let result: Option<crate::crates::Crate> =
if let Some(ex) = Experiment::get(&data.db, &experiment)? {
while let Some(next) = data.uncompleted_cache.lock().unwrap().pop_front() {
if next.0.elapsed() <= std::time::Duration::from_secs(60) {
if next.0.elapsed() <= std::time::Duration::from_secs(120) {
return Ok(Some(next.1));
}
}

let mut crates = ex.get_uncompleted_crates(&data.db, Some(100))?;
let mut crates = ex.get_uncompleted_crates(&data.db, Some(1000))?;
if crates.is_empty() {
None
} else {
Expand Down

0 comments on commit 24acc12

Please sign in to comment.