global: fixes

This commit is contained in:
nym21
2026-03-23 14:17:07 +01:00
parent d6def7643d
commit c53c6560fa
11 changed files with 38 additions and 39 deletions

6
Cargo.lock generated
View File

@@ -2545,8 +2545,6 @@ dependencies = [
[[package]] [[package]]
name = "rawdb" name = "rawdb"
version = "0.7.1" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc7e70161aa9dbfcc1f858cae94eda70c9073bab5b22167bc6ab0f85d27054cf"
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
@@ -3439,8 +3437,6 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23"
[[package]] [[package]]
name = "vecdb" name = "vecdb"
version = "0.7.1" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "417cdef9fd0ada1659e1499c7180b3b8edf5256b99eb846c7f960c10a755ea3c"
dependencies = [ dependencies = [
"itoa", "itoa",
"libc", "libc",
@@ -3462,8 +3458,6 @@ dependencies = [
[[package]] [[package]]
name = "vecdb_derive" name = "vecdb_derive"
version = "0.7.1" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aba470bc1a709df1efaace5885b25e7685988c64b61ac379758d861d12312735"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn",

View File

@@ -87,8 +87,8 @@ tower-http = { version = "0.6.8", features = ["catch-panic", "compression-br", "
tower-layer = "0.3" tower-layer = "0.3"
tracing = { version = "0.1", default-features = false, features = ["std"] } tracing = { version = "0.1", default-features = false, features = ["std"] }
ureq = { version = "3.3.0", features = ["json"] } ureq = { version = "3.3.0", features = ["json"] }
vecdb = { version = "0.7.1", features = ["derive", "serde_json", "pco", "schemars"] } # vecdb = { version = "0.7.1", features = ["derive", "serde_json", "pco", "schemars"] }
# vecdb = { path = "../anydb/crates/vecdb", features = ["derive", "serde_json", "pco", "schemars"] } vecdb = { path = "../anydb/crates/vecdb", features = ["derive", "serde_json", "pco", "schemars"] }
[workspace.metadata.release] [workspace.metadata.release]
shared-version = true shared-version = true

View File

@@ -894,7 +894,7 @@ mod tests {
is_suffix_mode: true, has_outlier: true, is_suffix_mode: true, has_outlier: true,
}; };
let mode = determine_pattern_mode(&[normal, outlier], &fields); let mode = determine_pattern_mode(&[normal, outlier], &fields);
assert!(mode.is_none(), "Pattern with outlier instance should be non-parameterizable"); assert!(mode.is_some(), "Outlier should be filtered out, leaving a valid pattern from non-outlier instances");
} }
#[test] #[test]

View File

@@ -3,7 +3,7 @@
use std::{ use std::{
fs, fs,
thread::{self, sleep}, thread::{self, sleep},
time::Duration, time::{Duration, Instant},
}; };
use brk_alloc::Mimalloc; use brk_alloc::Mimalloc;
@@ -99,6 +99,8 @@ pub fn main() -> anyhow::Result<()> {
info!("{} blocks found.", u32::from(last_height) + 1); info!("{} blocks found.", u32::from(last_height) + 1);
let total_start = Instant::now();
let starting_indexes = if cfg!(debug_assertions) { let starting_indexes = if cfg!(debug_assertions) {
indexer.checked_index(&blocks, &client, &exit)? indexer.checked_index(&blocks, &client, &exit)?
} else { } else {
@@ -109,6 +111,7 @@ pub fn main() -> anyhow::Result<()> {
computer.compute(&indexer, starting_indexes, &reader, &exit)?; computer.compute(&indexer, starting_indexes, &reader, &exit)?;
info!("Total time: {:?}", total_start.elapsed());
info!("Waiting for new blocks..."); info!("Waiting for new blocks...");
while last_height == client.get_last_height()? { while last_height == client.get_last_height()? {

View File

@@ -8,7 +8,7 @@ use brk_types::{
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use schemars::JsonSchema; use schemars::JsonSchema;
use vecdb::{ use vecdb::{
AggFold, Cursor, LazyAggVec, ReadOnlyClone, ReadableBoxedVec, ReadableVec, VecIndex, VecValue, AggFold, LazyAggVec, ReadOnlyClone, ReadableBoxedVec, ReadableVec, VecIndex, VecValue,
}; };
use crate::{ use crate::{
@@ -37,19 +37,18 @@ where
from: usize, from: usize,
to: usize, to: usize,
init: B, init: B,
mut f: F, f: F,
) -> Result<B, E> { ) -> Result<B, E> {
let mapping_len = mapping.len(); let mapping_len = mapping.len();
let source_len = source.len(); let source_len = source.len();
let mut cursor = Cursor::new(source);
let mut acc = init; let indices: Vec<usize> = (from..to.min(mapping_len))
for i in from..to.min(mapping_len) { .map(|i| S1I::max_from(I::from(i), source_len))
let target = S1I::max_from(I::from(i), source_len); .collect();
if let Some(v) = cursor.get(target) {
acc = f(acc, v)?; let values = source.read_sorted_at(&indices);
}
} values.into_iter().try_fold(init, f)
Ok(acc)
} }
#[inline] #[inline]

View File

@@ -22,17 +22,23 @@ impl ServerRoutes for ApiRouter<AppState> {
get_with( get_with(
async |State(state): State<AppState>| -> axum::Json<Health> { async |State(state): State<AppState>| -> axum::Json<Health> {
let uptime = state.started_instant.elapsed(); let uptime = state.started_instant.elapsed();
let tip_height = state.client.get_last_height(); let started_at = state.started_at.to_string();
let sync = state.sync(|q| { let sync = state
let tip_height = tip_height.unwrap_or(q.indexed_height()); .run(move |q| {
q.sync_status(tip_height) let tip_height = q
}); .client()
.get_last_height()
.unwrap_or(q.indexed_height());
Ok(q.sync_status(tip_height))
})
.await
.expect("health sync task panicked");
axum::Json(Health { axum::Json(Health {
status: Cow::Borrowed("healthy"), status: Cow::Borrowed("healthy"),
service: Cow::Borrowed("brk"), service: Cow::Borrowed("brk"),
version: Cow::Borrowed(VERSION), version: Cow::Borrowed(VERSION),
timestamp: jiff::Timestamp::now().to_string(), timestamp: jiff::Timestamp::now().to_string(),
started_at: state.started_at.to_string(), started_at,
uptime_seconds: uptime.as_secs(), uptime_seconds: uptime.as_secs(),
sync, sync,
}) })
@@ -70,11 +76,10 @@ impl ServerRoutes for ApiRouter<AppState> {
"/api/server/sync", "/api/server/sync",
get_with( get_with(
async |uri: Uri, headers: HeaderMap, State(state): State<AppState>| { async |uri: Uri, headers: HeaderMap, State(state): State<AppState>| {
let tip_height = state.client.get_last_height();
state state
.cached_json(&headers, CacheStrategy::Height, &uri, move |q| { .cached_json(&headers, CacheStrategy::Height, &uri, move |q| {
Ok(q.sync_status(tip_height?)) let tip_height = q.client().get_last_height()?;
Ok(q.sync_status(tip_height))
}) })
.await .await
}, },

View File

@@ -14,7 +14,8 @@ pub enum ContentEncoding {
impl ContentEncoding { impl ContentEncoding {
/// Negotiate the best encoding from the Accept-Encoding header. /// Negotiate the best encoding from the Accept-Encoding header.
/// Priority: br > zstd > gzip > identity. /// Priority: zstd > br > gzip > identity.
/// zstd is preferred over brotli: ~3-5x faster compression at comparable ratios.
pub fn negotiate(headers: &HeaderMap) -> Self { pub fn negotiate(headers: &HeaderMap) -> Self {
let accept = match headers.get(header::ACCEPT_ENCODING) { let accept = match headers.get(header::ACCEPT_ENCODING) {
Some(v) => v, Some(v) => v,
@@ -29,8 +30,8 @@ impl ContentEncoding {
for part in s.split(',') { for part in s.split(',') {
let name = part.split(';').next().unwrap_or("").trim(); let name = part.split(';').next().unwrap_or("").trim();
match name { match name {
"br" => return Self::Brotli, "zstd" => return Self::Zstd,
"zstd" => best = Self::Zstd, "br" => best = Self::Brotli,
"gzip" if matches!(best, Self::Identity) => best = Self::Gzip, "gzip" if matches!(best, Self::Identity) => best = Self::Gzip,
_ => {} _ => {}
} }

View File

@@ -54,7 +54,6 @@ impl Server {
pub fn new(query: &AsyncQuery, data_path: PathBuf, website: Website) -> Self { pub fn new(query: &AsyncQuery, data_path: PathBuf, website: Website) -> Self {
website.log(); website.log();
Self(AppState { Self(AppState {
client: query.client().clone(),
query: query.clone(), query: query.clone(),
data_path, data_path,
website, website,

View File

@@ -12,7 +12,6 @@ use axum::{
http::{HeaderMap, HeaderValue, Response, Uri, header}, http::{HeaderMap, HeaderValue, Response, Uri, header},
}; };
use brk_query::AsyncQuery; use brk_query::AsyncQuery;
use brk_rpc::Client;
use jiff::Timestamp; use jiff::Timestamp;
use quick_cache::sync::{Cache, GuardResult}; use quick_cache::sync::{Cache, GuardResult};
use serde::Serialize; use serde::Serialize;
@@ -29,7 +28,6 @@ pub struct AppState {
pub data_path: PathBuf, pub data_path: PathBuf,
pub website: Website, pub website: Website,
pub cache: Arc<Cache<String, Bytes>>, pub cache: Arc<Cache<String, Bytes>>,
pub client: Client,
pub started_at: Timestamp, pub started_at: Timestamp,
pub started_instant: Instant, pub started_instant: Instant,
} }

View File

@@ -243,7 +243,7 @@
button.capture { button.capture {
position: absolute; position: absolute;
top: -0.75rem; bottom: 0.325rem;
right: -0.75rem; right: -0.75rem;
z-index: 50; z-index: 50;
font-size: var(--font-size-xs); font-size: var(--font-size-xs);

View File

@@ -43,8 +43,8 @@
display: flex; display: flex;
white-space: nowrap; white-space: nowrap;
overflow-x: auto; overflow-x: auto;
padding-bottom: 1rem; padding-bottom: 0.25rem;
margin-bottom: -0.75rem; margin-bottom: -0.25rem;
padding-left: var(--main-padding); padding-left: var(--main-padding);
margin-left: var(--negative-main-padding); margin-left: var(--negative-main-padding);
padding-right: var(--main-padding); padding-right: var(--main-padding);