store: internal locking, remove Arc<Mutex<Store>> wrapper
Store now has internal Mutex for capnp appends and AtomicU64 for size tracking. All methods take &self. The external Arc<Mutex<Store>> is replaced with Arc<Store>. - Store::append_lock protects file appends - local.rs functions take &Store (not &mut Store) - access_local() returns Arc<Store> - All .lock().await calls removed from callers Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
4696bb8b7d
commit
b3d0a3ab25
13 changed files with 86 additions and 70 deletions
|
|
@ -26,8 +26,7 @@ pub async fn cmd_init() -> Result<()> {
|
|||
include_str!("../../defaults/on-consciousness.md"))?;
|
||||
|
||||
// Seed identity node if empty
|
||||
let arc = memory::access_local()?;
|
||||
let mut store = arc.lock().await;
|
||||
let store = memory::access_local()?;
|
||||
if !store.contains_key("identity").unwrap_or(false) {
|
||||
let default = include_str!("../../defaults/identity.md");
|
||||
store.upsert("identity", default)?;
|
||||
|
|
@ -60,8 +59,7 @@ pub async fn cmd_fsck() -> Result<()> {
|
|||
// Check/repair capnp log integrity first
|
||||
store::fsck()?;
|
||||
|
||||
let arc = memory::access_local()?;
|
||||
let store = arc.lock().await;
|
||||
let store = memory::access_local()?;
|
||||
|
||||
// Check node-key consistency
|
||||
let mut issues = 0;
|
||||
|
|
@ -115,8 +113,7 @@ pub async fn cmd_fsck() -> Result<()> {
|
|||
pub async fn cmd_dedup(apply: bool) -> Result<()> {
|
||||
use std::collections::HashMap;
|
||||
|
||||
let arc = memory::access_local()?;
|
||||
let mut store = arc.lock().await;
|
||||
let store = memory::access_local()?;
|
||||
let duplicates = store.find_duplicates()?;
|
||||
|
||||
if duplicates.is_empty() {
|
||||
|
|
@ -352,8 +349,7 @@ pub async fn cmd_topology() -> Result<()> {
|
|||
}
|
||||
|
||||
pub async fn cmd_daily_check() -> Result<()> {
|
||||
let arc = memory::access_local()?;
|
||||
let store = arc.lock().await;
|
||||
let store = memory::access_local()?;
|
||||
let report = crate::neuro::daily_check(&store);
|
||||
print!("{}", report);
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ use anyhow::{bail, Result};
|
|||
use crate::hippocampus as memory;
|
||||
|
||||
pub async fn cmd_cap_degree(max_deg: usize) -> Result<()> {
|
||||
let arc = memory::access_local()?;
|
||||
let mut store = arc.lock().await;
|
||||
let store = memory::access_local()?;
|
||||
let (hubs, pruned) = store.cap_degree(max_deg)?;
|
||||
store.save()?;
|
||||
println!("Capped {} hubs, pruned {} weak Auto edges (max_degree={})", hubs, pruned, max_deg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue