dev/perf-vm-allocation-and-copy-pressure #18

Merged
bquarkz merged 6 commits from dev/perf-vm-allocation-and-copy-pressure into master 2026-04-20 10:09:28 +00:00
Showing only changes of commit 8937963819 - Show all commits

View File

@ -1,10 +1,12 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::cell::Cell;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::fmt::Write; use std::fmt::Write;
use std::sync::atomic::{AtomicU64, Ordering as AtomicOrdering};
use std::sync::Arc; use std::sync::Arc;
static STRING_MATERIALIZATION_COUNT: AtomicU64 = AtomicU64::new(0); thread_local! {
static STRING_MATERIALIZATION_COUNT: Cell<u64> = const { Cell::new(0) };
}
/// Opaque handle that references an object stored in the VM heap. /// Opaque handle that references an object stored in the VM heap.
/// ///
@ -83,7 +85,7 @@ impl Value {
where where
S: Into<Arc<str>>, S: Into<Arc<str>>,
{ {
STRING_MATERIALIZATION_COUNT.fetch_add(1, AtomicOrdering::Relaxed); STRING_MATERIALIZATION_COUNT.with(|count| count.set(count.get() + 1));
Value::String(value.into()) Value::String(value.into())
} }
@ -149,7 +151,7 @@ impl Value {
} }
pub fn string_materialization_count() -> u64 { pub fn string_materialization_count() -> u64 {
STRING_MATERIALIZATION_COUNT.load(AtomicOrdering::Relaxed) STRING_MATERIALIZATION_COUNT.with(Cell::get)
} }
#[cfg(test)] #[cfg(test)]