Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 198 additions & 92 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@

3. Grab the binaries from `target/release/libbytehound.so` and `target/release/bytehound`

### Build notes (newer nightlies / GCC 15+)

- If `cc` is missing, install `build-essential` (or your distro's equivalent).
- `mimalloc` can fail under newer GCC defaults (C23) with `ATOMIC_VAR_INIT` errors; build with `CFLAGS='-std=gnu11'`, e.g.:

$ CFLAGS='-std=gnu11' cargo build --release -p bytehound-preload
$ CFLAGS='-std=gnu11' cargo build --release -p bytehound-cli

- Recent nightly toolchains removed the `stdsimd` feature gate; older `ahash` build scripts can still try to enable `stdsimd`/`specialize`, which can fail with `unknown feature stdsimd`.
Prefer bumping `ahash` to a newer 0.8.x release that no longer emits those cfgs.
- This repo uses the crates.io `version_check` crate. If you hit feature-gate errors on newer nightlies, consider updating dependencies (notably `ahash`) or using a toolchain that matches the repo's expectations.

## Usage

### Basic usage
Expand Down
10 changes: 5 additions & 5 deletions cli-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ cpp_demangle = "0.2"
chrono = "0.4"
libc = "0.2"
log = "0.4"
lru = "0.6"
lru = "0.16.3"
bitflags = "1"
inferno = { version = "0.9", default-features = false }
lazy_static = "1"
ahash = "0.7"
ahash = "0.8.12"
parking_lot = "0.12"
crossbeam-channel = "0.5"
rayon = "1"
regex = "1"
rhai = { version = "1", features = ["unchecked"] }
rhai = { version = "1.24.0", features = ["unchecked"] }
plotters = { version = "0.3", default-features = false, features = ["svg_backend", "all_series"] }
colorgrad = "0.4"
serde_json = "1"
Expand All @@ -34,8 +34,8 @@ lz4-compress = { path = "../lz4-compress" }
fast_range_map = { path = "../fast_range_map" }

[dependencies.nwind]
git = "https://github.com/koute/not-perf.git"
rev = "911723c"
git = "https://github.com/litlep-nibbyt/not-perf"
rev = "8117c91"

[dev-dependencies]
quickcheck = "0.9"
1 change: 1 addition & 0 deletions lz4-compress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "lz4-compress"
version = "0.1.1"
authors = ["ticki <Ticki@users.noreply.github.com>"]
edition = "2018"
description = "Pure Rust implementation of raw LZ4 compression/decompression."
repository = "https://github.com/ticki/tfs"
documentation = "https://docs.rs/lz4-compress"
Expand Down
16 changes: 8 additions & 8 deletions preload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ sc = { version = "0.2", optional = true }
lazy_static = "1"
log = "0.4"
glob = "0.2"
lru = { version = "0.6", default-features = false }
lru = { version = "0.16.3", default-features = false }
tikv-jemalloc-sys = { path = "../jemallocator/jemalloc-sys", default-features = false }
mimalloc = { path = "../mimalloc_rust", default-features = false }
goblin = "0.0.24"
smallvec = { version = "1", features = ["union"] }
ahash = "0.8"
ahash = "0.8.12"
hashbrown = "0.13"

fast_range_map = { path = "../fast_range_map" }

[dependencies.thread-local-reentrant]
git = "https://github.com/koute/not-perf.git"
rev = "911723c"
git = "https://github.com/litlep-nibbyt/not-perf"
rev = "8117c91"

[dependencies.nwind]
git = "https://github.com/koute/not-perf.git"
rev = "911723c"
git = "https://github.com/litlep-nibbyt/not-perf"
rev = "8117c91"
features = ["log", "local-unwinding"]
default-features = false

[dependencies.perf_event_open]
git = "https://github.com/koute/not-perf.git"
rev = "911723c"
git = "https://github.com/litlep-nibbyt/not-perf"
rev = "8117c91"

[dependencies.common]
path = "../common"
Expand Down
4 changes: 2 additions & 2 deletions preload/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn sync() {
try_sync_processing_thread_destruction();
}

pub extern fn on_exit() {
pub extern "C" fn on_exit() {
if STATE.load( Ordering::SeqCst ) == STATE_PERMANENTLY_DISABLED {
return;
}
Expand All @@ -203,7 +203,7 @@ pub extern fn on_exit() {
info!( "Exit hook finished" );
}

pub unsafe extern fn on_fork() {
pub unsafe extern "C" fn on_fork() {
STATE.store( STATE_PERMANENTLY_DISABLED, Ordering::SeqCst );
DESIRED_STATE.store( DESIRED_STATE_DISABLED, Ordering::SeqCst );
THREAD_RUNNING.store( false, Ordering::SeqCst );
Expand Down
4 changes: 2 additions & 2 deletions preload/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ pub fn initialize_signal_handlers() {
if opt::get().register_sigusr1 {
info!( "Registering SIGUSR1 handler..." );
unsafe {
libc::signal( libc::SIGUSR1, sigusr_handler as libc::sighandler_t );
libc::signal( libc::SIGUSR1, sigusr_handler as *const () as libc::sighandler_t );
}
}

if opt::get().register_sigusr2 {
info!( "Registering SIGUSR2 handler..." );
unsafe {
libc::signal( libc::SIGUSR2, sigusr_handler as libc::sighandler_t );
libc::signal( libc::SIGUSR2, sigusr_handler as *const () as libc::sighandler_t );
}
}
}
9 changes: 7 additions & 2 deletions preload/src/processing_thread.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::hash::Hash;
use std::mem;
use std::num::NonZeroUsize;
use std::fs::{self, File, remove_file};
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
use std::net::{TcpListener, TcpStream, UdpSocket, IpAddr, SocketAddr};
Expand Down Expand Up @@ -424,7 +425,7 @@ impl BacktraceCache {
pub fn new( cache_size: usize ) -> Self {
BacktraceCache {
next_id: 1,
cache: lru::LruCache::with_hasher( cache_size, NoHash )
cache: lru::LruCache::with_hasher( nonzero_or_one( cache_size ), NoHash )
}
}

Expand All @@ -438,7 +439,7 @@ impl BacktraceCache {
match self.cache.get_mut( &key ) {
None => {
if cfg!( debug_assertions ) {
if self.cache.len() >= self.cache.cap() {
if self.cache.len() >= self.cache.cap().get() {
debug!( "2nd level backtrace cache overflow" );
}
}
Expand Down Expand Up @@ -469,6 +470,10 @@ impl BacktraceCache {
}
}

fn nonzero_or_one( size: usize ) -> NonZeroUsize {
NonZeroUsize::new( size ).unwrap_or_else( || NonZeroUsize::new( 1 ).unwrap() )
}

fn emit_allocation_bucket( mut bucket: AllocationBucket, backtrace_cache: &mut BacktraceCache, fp: &mut impl Write ) -> Result< (), std::io::Error > {
if bucket.events.len() == 0 {
return Ok(());
Expand Down
4 changes: 2 additions & 2 deletions preload/src/spin_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ impl< T > SpinLock< T > {
}
}

pub fn lock( &self ) -> SpinLockGuard< T > {
pub fn lock( &self ) -> SpinLockGuard<'_, T > {
while self.flag.compare_exchange_weak( false, true, Ordering::Acquire, Ordering::Acquire ).is_err() {
}

SpinLockGuard( self )
}

pub fn try_lock( &self ) -> Option< SpinLockGuard< T > > {
pub fn try_lock( &self ) -> Option< SpinLockGuard<'_, T > > {
if self.flag.compare_exchange( false, true, Ordering::Acquire, Ordering::Acquire ).is_ok() {
Some( SpinLockGuard( self ) )
} else {
Expand Down
14 changes: 11 additions & 3 deletions preload/src/unwind.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::mem::{self, transmute};
use std::num::NonZeroUsize;
use std::sync::atomic::{AtomicU64, AtomicUsize};
use libc::{self, c_void, c_int, uintptr_t};
use perf_event_open::{Perf, EventSource, Event};
Expand Down Expand Up @@ -132,11 +133,18 @@ impl ThreadUnwindState {
last_dl_state: (0, 0),
current_backtrace: Vec::new(),
buffer: Vec::new(),
cache: lru::LruCache::with_hasher( crate::opt::get().backtrace_cache_size_level_1, NoHash )
cache: lru::LruCache::with_hasher(
nonzero_or_one( crate::opt::get().backtrace_cache_size_level_1 ),
NoHash
)
}
}
}

fn nonzero_or_one( size: usize ) -> NonZeroUsize {
NonZeroUsize::new( size ).unwrap_or_else( || NonZeroUsize::new( 1 ).unwrap() )
}

type Context = *mut c_void;
type ReasonCode = c_int;
type Callback = extern "C" fn( Context, *mut c_void ) -> ReasonCode;
Expand Down Expand Up @@ -303,7 +311,7 @@ fn reload_if_necessary_dl_iterate_phdr( last_state: &mut (u64, u64) ) -> RwLockR
}

fn get_dl_state() -> (u64, u64) {
unsafe extern fn callback( info: *mut libc::dl_phdr_info, _: libc::size_t, data: *mut libc::c_void ) -> libc::c_int {
unsafe extern "C" fn callback( info: *mut libc::dl_phdr_info, _: libc::size_t, data: *mut libc::c_void ) -> libc::c_int {
let out = &mut *(data as *mut (u64, u64));
out.0 = (*info).dlpi_adds;
out.1 = (*info).dlpi_subs;
Expand Down Expand Up @@ -438,7 +446,7 @@ fn grab_with_unwind_state( unwind_state: &mut ThreadUnwindState ) -> Backtrace {
let backtrace = match unwind_state.cache.get_mut( &key ) {
None => {
if cfg!( debug_assertions ) {
if unwind_state.cache.len() >= unwind_state.cache.cap() {
if unwind_state.cache.len() >= unwind_state.cache.cap().get() {
debug!( "1st level backtrace cache overflow" );
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-10-13
nightly-2025-11-26
4 changes: 2 additions & 2 deletions server-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ futures = "0.1"
serde_urlencoded = "0.5"
regex = "1"
bytes = "0.4"
lru = "0.6"
lru = "0.16.3"
parking_lot = "0.12"
common = { path = "../common" }
ahash = "0.7"
ahash = "0.8.12"
rayon = "1"
md5 = "0.7"

Expand Down
3 changes: 2 additions & 1 deletion server-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::io;
use std::borrow::Cow;
use std::cmp::{min, max};
use std::path::PathBuf;
use std::num::NonZeroUsize;
use std::time::Instant;

use actix_web::{
Expand Down Expand Up @@ -190,7 +191,7 @@ impl State {
State {
data: HashMap::new(),
data_ids: Vec::new(),
allocation_group_cache: Mutex::new( LruCache::new( 4 ) ),
allocation_group_cache: Mutex::new( LruCache::new( NonZeroUsize::new( 4 ).unwrap() ) ),
generated_files: Default::default(),
}
}
Expand Down
5 changes: 5 additions & 0 deletions webui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,11 @@
resolved "https://registry.yarnpkg.com/@parcel/css-linux-arm64-gnu/-/css-linux-arm64-gnu-1.10.0.tgz#7229d05f1f9f76443eb4c9bc55a9e8887c0822dd"
integrity sha512-x8XEtJxgJlstAwbg1BLeYuXhUXEOxGg/BeBFPZr8Zk8dNQ1j1jR7LBk12IKgZrvr+Px1WOFY65lwabgCyFqxnQ==

"@parcel/css-linux-arm64-gnu@^1.13.1":
version "1.13.1"
resolved "https://registry.yarnpkg.com/@parcel/css-linux-arm64-gnu/-/css-linux-arm64-gnu-1.13.1.tgz#fa4c43564b6bfc5434ab779cbef58de7b1228994"
integrity sha512-FxnOONVo8WBW58uzjqv/mwSBDgGMp1qxK+fovjqLPCP3zcNgxkUG0l6ElWpqtiWWH3mTMzSHe+7hSaeVov12yQ==

"@parcel/css-linux-arm64-musl@1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@parcel/css-linux-arm64-musl/-/css-linux-arm64-musl-1.10.0.tgz#d8efb7c09f53971db01ea180a5b63a1b908f1800"
Expand Down