computer: snapshot

This commit is contained in:
nym21
2025-12-28 14:57:25 +01:00
parent e77d338357
commit f08ac7f916
81 changed files with 1394 additions and 930 deletions

View File

@@ -5,6 +5,7 @@ use std::{
time::{Duration, Instant},
};
use brk_alloc::Mimalloc;
use brk_computer::Computer;
use brk_error::Result;
use brk_fetcher::Fetcher;
@@ -12,12 +13,8 @@ use brk_indexer::Indexer;
use brk_iterator::Blocks;
use brk_reader::Reader;
use brk_rpc::{Auth, Client};
use mimalloc::MiMalloc;
use vecdb::Exit;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
pub fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
@@ -56,11 +53,24 @@ fn run() -> Result<()> {
let exit = Exit::new();
exit.set_ctrlc_handler();
// Pre-run indexer if too far behind, then drop and reimport to reduce memory
let chain_height = client.get_last_height()?;
let indexed_height = indexer.vecs.starting_height();
if u32::from(chain_height) - u32::from(indexed_height) > 1000 {
indexer.checked_index(&blocks, &client, &exit)?;
drop(indexer);
Mimalloc::collect();
indexer = Indexer::forced_import(&outputs_dir)?;
}
let mut computer = Computer::forced_import(&outputs_dir, &indexer, Some(fetcher))?;
loop {
let i = Instant::now();
let starting_indexes = indexer.checked_index(&blocks, &client, &exit)?;
Mimalloc::collect_if_wasted_above(500);
computer.compute(&indexer, starting_indexes, &reader, &exit)?;
dbg!(i.elapsed());
sleep(Duration::from_secs(10));

View File

@@ -1,5 +1,6 @@
use std::{env, path::Path, thread, time::Instant};
use brk_alloc::Mimalloc;
use brk_bencher::Bencher;
use brk_computer::Computer;
use brk_error::Result;
@@ -9,12 +10,8 @@ use brk_iterator::Blocks;
use brk_reader::Reader;
use brk_rpc::{Auth, Client};
use log::{debug, info};
use mimalloc::MiMalloc;
use vecdb::Exit;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
pub fn main() -> Result<()> {
// Can't increase main thread's stack size, thus we need to use another thread
thread::Builder::new()
@@ -65,6 +62,8 @@ fn run() -> Result<()> {
let starting_indexes = indexer.index(&blocks, &client, &exit)?;
info!("Done in {:?}", i.elapsed());
Mimalloc::collect_if_wasted_above(500);
let i = Instant::now();
computer.compute(&indexer, starting_indexes, &reader, &exit)?;
info!("Done in {:?}", i.elapsed());

View File

@@ -4,12 +4,8 @@ use brk_computer::Computer;
use brk_error::Result;
use brk_fetcher::Fetcher;
use brk_indexer::Indexer;
use mimalloc::MiMalloc;
use vecdb::{AnyStoredVec, Exit};
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
pub fn main() -> Result<()> {
// Can't increase main thread's stack size, thus we need to use another thread
thread::Builder::new()

View File

@@ -5,6 +5,7 @@ use std::{
time::{Duration, Instant},
};
use brk_alloc::Mimalloc;
use brk_bencher::Bencher;
use brk_computer::Computer;
use brk_error::Result;
@@ -14,12 +15,8 @@ use brk_iterator::Blocks;
use brk_reader::Reader;
use brk_rpc::{Auth, Client};
use log::{debug, info};
use mimalloc::MiMalloc;
use vecdb::Exit;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
pub fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
@@ -76,6 +73,8 @@ fn run() -> Result<()> {
let starting_indexes = indexer.index(&blocks, &client, &exit)?;
info!("Done in {:?}", i.elapsed());
Mimalloc::collect_if_wasted_above(500);
let i = Instant::now();
computer.compute(&indexer, starting_indexes, &reader, &exit)?;
info!("Done in {:?}", i.elapsed());