Merge pull request #796 from rdbtCVS/t3/optimize-noise-aquifers

🤖 Agent: merged, thanks rdbt! Bulk density arithmetic, the shared Beardifier kernel and Perlin column reuse: 12.685 → 10.069 ms/chunk Overworld terrain (−20.6 %, one worker). We merged current main in (density/tests.rs: kept both test sets) and checked it together with #955/#956/#959: fmt, clippy -D warnings, 359 core/world/port-pack tests, and 14 world-gen harnesses (density, noise, structure_density, server_world_gen, world_spawn, decorated_region, …) all pass.
This commit is contained in:
Ludovic Marie
2026-10-19 08:09:26 +02:00
committed by GitHub
5 changed files with 473 additions and 21 deletions
+269 -9
View File
@@ -75,9 +75,12 @@ pub enum UnaryOp {
max: f32,
},
}
impl UnaryOp {
pub(super) fn apply(self, value: f32, bulk: bool) -> f32 {
match self {
// One expression definition for scalar dispatch and specialized bulk loops.
macro_rules! unary_apply {
($operation:expr, $value:expr, $bulk:expr) => {{
let value = $value;
let bulk = $bulk;
match $operation {
Self::Abs => value.abs(),
Self::Negate => -value,
Self::Square => value * value,
@@ -137,6 +140,85 @@ impl UnaryOp {
}
}
}
}};
}
impl UnaryOp {
pub(super) fn apply(self, value: f32, bulk: bool) -> f32 {
unary_apply!(self, value, bulk)
}
/// Dispatch once per volume so each loop has one fixed arithmetic operation.
/// Keep the scalar expression shared, including the bulk min/max behavior.
fn apply_bulk(self, buffer: &mut [f32]) {
// Specialization can reverse which NaN operand supplies the payload.
// Retain the original dispatch for non-finite constant operands.
let non_finite = match self {
Self::PowerBase(value) | Self::PowerExponent(value) => !value.is_finite(),
Self::LeakyRelu(value)
| Self::Add(value)
| Self::SubtractFrom(value)
| Self::Multiply(value)
| Self::DivideInto(value)
| Self::Minimum(value)
| Self::Maximum(value) => !value.is_finite(),
Self::Clamp { min, max } => !min.is_finite() || !max.is_finite(),
Self::ConstantRangeChoice {
min_inclusive,
max_exclusive,
inside,
outside,
} => {
!min_inclusive.is_finite()
|| !max_exclusive.is_finite()
|| !inside.is_finite()
|| !outside.is_finite()
}
_ => false,
};
if non_finite {
for value in buffer {
*value = self.apply(*value, true);
}
return;
}
macro_rules! apply {
($operation:expr) => {
for value in buffer {
*value = unary_apply!($operation, *value, true);
}
};
}
match self {
Self::Abs => apply!(Self::Abs),
Self::Negate => apply!(Self::Negate),
Self::Square => apply!(Self::Square),
Self::Cube => apply!(Self::Cube),
Self::Sqrt => apply!(Self::Sqrt),
Self::Log => apply!(Self::Log),
Self::PowerBase(base) => apply!(Self::PowerBase(base)),
Self::PowerExponent(exponent) => apply!(Self::PowerExponent(exponent)),
Self::Reciprocal => apply!(Self::Reciprocal),
Self::Sign => apply!(Self::Sign),
Self::Squeeze => apply!(Self::Squeeze),
Self::LeakyRelu(factor) => apply!(Self::LeakyRelu(factor)),
Self::Add(right) => apply!(Self::Add(right)),
Self::SubtractFrom(left) => apply!(Self::SubtractFrom(left)),
Self::Multiply(right) => apply!(Self::Multiply(right)),
Self::DivideInto(left) => apply!(Self::DivideInto(left)),
Self::Minimum(right) => apply!(Self::Minimum(right)),
Self::Maximum(right) => apply!(Self::Maximum(right)),
Self::ConstantRangeChoice {
min_inclusive,
max_exclusive,
inside,
outside,
} => apply!(Self::ConstantRangeChoice {
min_inclusive,
max_exclusive,
inside,
outside
}),
Self::Clamp { min, max } => apply!(Self::Clamp { min, max }),
}
}
}
#[derive(Clone, Debug)]
@@ -162,9 +244,7 @@ impl DensitySampler for UnarySampler {
) -> Result<(), SampleError> {
check_buffer(buffer, volume)?;
self.input.sample_volume(context, buffer, volume)?;
for value in buffer {
*value = self.operation.apply(*value, true);
}
self.operation.apply_bulk(buffer);
Ok(())
}
}
@@ -203,6 +283,23 @@ impl BinaryOp {
}
}
}
fn apply_bulk(self, buffer: &mut [f32], right: &[f32]) {
macro_rules! apply {
($operation:expr) => {
for (left, &right) in buffer.iter_mut().zip(right) {
*left = ($operation)(*left, right);
}
};
}
match self {
Self::Add => apply!(|left, right| left + right),
Self::Subtract => apply!(|left, right| left - right),
Self::Multiply => apply!(|left, right| left * right),
Self::Divide => apply!(|left, right| left / right),
Self::Minimum { .. } => apply!(|left, right| if right < left { right } else { left }),
Self::Maximum { .. } => apply!(|left, right| if right > left { right } else { left }),
}
}
}
#[derive(Clone, Debug)]
pub struct BinarySampler {
@@ -239,10 +336,173 @@ impl DensitySampler for BinarySampler {
self.left.sample_volume(context, buffer, volume)?;
context.with_buffer(volume.size(), |context, right| {
self.right.sample_volume(context, right, volume)?;
for (left, right) in buffer.iter_mut().zip(right) {
*left = self.operation.apply(*left, *right, true);
}
self.operation.apply_bulk(buffer, right);
Ok(())
})
}
}
#[cfg(test)]
mod bulk_tests {
use super::*;
#[inline(never)]
fn dispatched_reference(operation: UnaryOp, value: f32) -> f32 {
operation.apply(value, true)
}
#[test]
fn fixed_operation_loops_preserve_float_bits() {
let mut operations = vec![
UnaryOp::Abs,
UnaryOp::Negate,
UnaryOp::Square,
UnaryOp::Cube,
UnaryOp::Sqrt,
UnaryOp::Log,
UnaryOp::Reciprocal,
UnaryOp::Sign,
UnaryOp::Squeeze,
];
for factor in [0.0, -0.0, 0.5, -1.0, f32::INFINITY, f32::NAN] {
operations.extend([
UnaryOp::LeakyRelu(factor),
UnaryOp::Add(factor),
UnaryOp::SubtractFrom(factor),
UnaryOp::Multiply(factor),
UnaryOp::DivideInto(factor),
UnaryOp::Minimum(factor),
UnaryOp::Maximum(factor),
UnaryOp::Clamp {
min: -factor,
max: factor,
},
UnaryOp::ConstantRangeChoice {
min_inclusive: -factor,
max_exclusive: factor,
inside: -0.0,
outside: 17.0,
},
]);
}
for exponent in [0.0, -0.0, 0.5, -1.0, 2.0, 3.0, f64::INFINITY, f64::NAN] {
operations.extend([
UnaryOp::PowerBase(exponent),
UnaryOp::PowerExponent(exponent),
]);
}
let mut values: Vec<f32> = [
0,
0x8000_0000,
1,
0x8000_0001,
0x007f_ffff,
0x0080_0000,
0x3f00_0000,
0xbf00_0000,
0x3f80_0000,
0xbf80_0000,
0x7f7f_ffff,
0xff7f_ffff,
0x7f80_0000,
0xff80_0000,
0x7fc0_0000,
0x7fa0_0001,
0xffc0_1234,
]
.into_iter()
.map(f32::from_bits)
.collect();
let mut bits = 0x484f_5249u32;
for _ in 0..4096 {
bits ^= bits << 13;
bits ^= bits >> 17;
bits ^= bits << 5;
values.push(f32::from_bits(bits));
}
for operation in operations {
for length in [0, 1, 3, 16, 257, values.len()] {
let mut actual = values[..length].to_vec();
operation.apply_bulk(&mut actual);
for (i, (&input, actual)) in values.iter().zip(actual).enumerate() {
let expected = dispatched_reference(operation, input);
assert_eq!(
actual.to_bits(),
expected.to_bits(),
"{operation:?}, index {i}, input {input:?}"
);
}
}
}
}
#[inline(never)]
fn dispatched_binary_reference(operation: BinaryOp, left: f32, right: f32) -> f32 {
operation.apply(left, right, true)
}
#[test]
fn fixed_binary_loops_preserve_float_bits() {
let edges = [
0,
0x8000_0000,
1,
0x8000_0001,
0x007f_ffff,
0x0080_0000,
0x3f80_0000,
0xbf80_0000,
0x7f7f_ffff,
0xff7f_ffff,
0x7f80_0000,
0xff80_0000,
0x7fc0_0000,
0x7fa0_0001,
0xffc0_1234,
];
let mut left = Vec::new();
let mut right = Vec::new();
for a in edges {
for b in edges {
left.push(f32::from_bits(a));
right.push(f32::from_bits(b));
}
}
let mut bits = 0x484f_5249u32;
for _ in 0..8192 {
bits ^= bits << 13;
bits ^= bits >> 17;
bits ^= bits << 5;
left.push(f32::from_bits(bits));
bits ^= bits << 13;
bits ^= bits >> 17;
bits ^= bits << 5;
right.push(f32::from_bits(bits));
}
for operation in [
BinaryOp::Add,
BinaryOp::Subtract,
BinaryOp::Multiply,
BinaryOp::Divide,
BinaryOp::Minimum {
right_min: f32::NEG_INFINITY,
},
BinaryOp::Maximum {
right_max: f32::INFINITY,
},
] {
for length in [0, 1, 3, 16, 257, left.len()] {
let mut actual = left[..length].to_vec();
operation.apply_bulk(&mut actual, &right[..length]);
for (i, actual) in actual.into_iter().enumerate() {
let expected = dispatched_binary_reference(operation, left[i], right[i]);
assert_eq!(
actual.to_bits(),
expected.to_bits(),
"{operation:?}, index {i}"
);
}
}
}
}
}
@@ -77,6 +77,9 @@ impl Beardifier {
}
fn sample_unchecked(&self, [x, y, z]: [i32; 3]) -> f32 {
let mut value = 0.;
// The kernel is a process-wide constant; resolving it once keeps the
// per-piece and per-junction beard evaluations off the OnceLock.
let kernel = kernel();
for piece in &self.pieces {
let low = piece.bounds.minimum;
let high = piece.bounds.maximum;
@@ -98,7 +101,7 @@ impl Beardifier {
TerrainAdjustment::None => 0.,
TerrainAdjustment::Bury => bury(dx as f32, distance_y as f32 / 2., dz as f32),
TerrainAdjustment::BeardThin | TerrainAdjustment::BeardBox => {
beard(dx, distance_y, dz, dy) * 0.8
beard(kernel, dx, distance_y, dz, dy) * 0.8
}
TerrainAdjustment::Encapsulate => {
bury(dx as f32 / 2., distance_y as f32 / 2., dz as f32 / 2.) * 0.8
@@ -109,7 +112,7 @@ impl Beardifier {
let dx = x.wrapping_sub(junction.source_x);
let dy = y.wrapping_sub(junction.source_ground_y);
let dz = z.wrapping_sub(junction.source_z);
value += beard(dx, dy, dz, dy) * 0.4;
value += beard(kernel, dx, dy, dz, dy) * 0.4;
}
value
}
@@ -184,7 +187,7 @@ fn bury(x: f32, y: f32, z: f32) -> f32 {
1. - squared.sqrt() / 6.
}
}
fn beard(x: i32, y: i32, z: i32, ground_delta: i32) -> f32 {
fn beard(kernel: &[f32; 13824], x: i32, y: i32, z: i32, ground_delta: i32) -> f32 {
let indices = [x, y, z].map(|v| v.wrapping_add(12));
if indices.iter().any(|v| !(0..24).contains(v)) {
return 0.;
@@ -192,7 +195,7 @@ fn beard(x: i32, y: i32, z: i32, ground_delta: i32) -> f32 {
let vertical = ground_delta as f32 + 0.5;
let squared = (x as f32 * x as f32 + vertical * vertical) + z as f32 * z as f32;
let factor = (-vertical * fast_inverse_sqrt(f64::from(squared / 2.)) as f32) / 2.;
factor * kernel()[((indices[2] * 24 + indices[0]) * 24 + indices[1]) as usize]
factor * kernel[((indices[2] * 24 + indices[0]) * 24 + indices[1]) as usize]
}
fn fast_inverse_sqrt(value: f64) -> f64 {
let half = 0.5 * value;
+112
View File
@@ -847,3 +847,115 @@ fn reset_after_sampling_error_drops_blender_and_preserves_uncached_mode() {
})
.unwrap();
}
#[test]
fn unary_bulk_keeps_child_failure_writes_and_full_buffer_tail() {
#[derive(Debug)]
struct PartialInput;
impl DensitySampler for PartialInput {
fn sample_value(&self, _: &mut SamplerContext, _: [i32; 3]) -> Result<f32, SampleError> {
Err(SampleError::ZeroGradientPeriod)
}
fn sample_volume(
&self,
_: &mut SamplerContext,
buffer: &mut [f32],
_: DensityVolume,
) -> Result<(), SampleError> {
buffer[0] = -3.0;
Err(SampleError::ZeroGradientPeriod)
}
}
let volume = DensityVolume::new([1; 3], [0; 3], [1; 3]).unwrap();
let mut context = SamplerContext::default();
let mut buffer = [17.0; 3];
let sampler = UnarySampler {
input: Arc::new(PartialInput),
operation: UnaryOp::Square,
};
assert_eq!(
sampler.sample_volume(&mut context, &mut buffer, volume),
Err(SampleError::ZeroGradientPeriod)
);
assert_eq!(buffer, [-3.0, 17.0, 17.0]);
let sampler = UnarySampler {
input: Arc::new(ConstantSampler(-3.0)),
operation: UnaryOp::Square,
};
sampler
.sample_volume(&mut context, &mut buffer, volume)
.unwrap();
assert_eq!(buffer, [9.0; 3]);
}
#[test]
fn binary_bulk_preserves_child_failure_order_and_output() {
#[derive(Debug)]
struct Input {
name: &'static str,
value: f32,
fail: bool,
calls: Arc<std::sync::Mutex<Vec<&'static str>>>,
}
impl DensitySampler for Input {
fn sample_value(&self, _: &mut SamplerContext, _: [i32; 3]) -> Result<f32, SampleError> {
unreachable!("bulk-only fixture")
}
fn sample_volume(
&self,
_: &mut SamplerContext,
buffer: &mut [f32],
_: DensityVolume,
) -> Result<(), SampleError> {
self.calls.lock().unwrap().push(self.name);
buffer.fill(self.value);
if self.fail {
Err(SampleError::ZeroGradientPeriod)
} else {
Ok(())
}
}
}
let volume = DensityVolume::new([1; 3], [0; 3], [1; 3]).unwrap();
for left_fails in [true, false] {
let calls = Arc::new(std::sync::Mutex::new(Vec::new()));
let sampler = BinarySampler {
left: Arc::new(Input {
name: "left",
value: 3.0,
fail: left_fails,
calls: calls.clone(),
}),
right: Arc::new(Input {
name: "right",
value: 7.0,
fail: true,
calls: calls.clone(),
}),
operation: BinaryOp::Multiply,
};
let mut context = SamplerContext::default();
let mut wrong_size = [17.0; 2];
assert!(
sampler
.sample_volume(&mut context, &mut wrong_size, volume)
.is_err()
);
assert_eq!(wrong_size, [17.0; 2]);
assert!(calls.lock().unwrap().is_empty());
let mut output = [17.0];
assert_eq!(
sampler.sample_volume(&mut context, &mut output, volume),
Err(SampleError::ZeroGradientPeriod)
);
assert_eq!(output, [3.0]);
assert_eq!(
*calls.lock().unwrap(),
if left_fails {
vec!["left"]
} else {
vec!["left", "right"]
}
);
}
}
+21 -8
View File
@@ -40,18 +40,29 @@ impl PerlinNoise {
}
fn gradients(&self, cell: [i32; 3]) -> [[i32; 3]; 8] {
let p = self.table.permute(cell[0]);
let q = self.table.permute(cell[0].wrapping_add(1));
let lower = self.table.permute(p.wrapping_add(cell[1]));
let upper = self.table.permute(p.wrapping_add(cell[1]).wrapping_add(1));
let lower_x = self.table.permute(q.wrapping_add(cell[1]));
let upper_x = self.table.permute(q.wrapping_add(cell[1]).wrapping_add(1));
self.gradients_at(
self.table.permute(cell[0]),
self.table.permute(cell[0].wrapping_add(1)),
cell[1],
cell[2],
)
}
/// Corner gradients for a Y cell, with the X column's permutation already
/// resolved. `add_volume` reuses one X column across every Y, so hoisting
/// the two X permutes out of that loop avoids repeating them per Y.
#[inline]
fn gradients_at(&self, p: i32, q: i32, cell_y: i32, cell_z: i32) -> [[i32; 3]; 8] {
let lower = self.table.permute(p.wrapping_add(cell_y));
let upper = self.table.permute(p.wrapping_add(cell_y).wrapping_add(1));
let lower_x = self.table.permute(q.wrapping_add(cell_y));
let upper_x = self.table.permute(q.wrapping_add(cell_y).wrapping_add(1));
let rows = [
lower, lower_x, upper, upper_x, lower, lower_x, upper, upper_x,
];
std::array::from_fn(|i| {
self.table
.gradient(rows[i].wrapping_add(cell[2]).wrapping_add((i / 4) as i32))
.gradient(rows[i].wrapping_add(cell_z).wrapping_add((i / 4) as i32))
})
}
@@ -166,6 +177,8 @@ impl PerlinNoise {
let cell_x = floor_i32(shifted_x);
let dx = (shifted_x - f64::from(cell_x)) as f32;
let fade_x = smoothstep(dx);
let p = self.table.permute(cell_x);
let q = self.table.permute(cell_x.wrapping_add(1));
let mut previous_y = i32::MIN;
let mut xz_dots = [0.0_f32; 8];
let mut y_gradients = [0.0_f32; 8];
@@ -176,7 +189,7 @@ impl PerlinNoise {
let dy = shifted_y - f64::from(cell_y);
let fade_y = smoothstep(dy as f32);
if previous_y != cell_y {
let gradients = self.gradients([cell_x, cell_y, cell_z]);
let gradients = self.gradients_at(p, q, cell_y, cell_z);
for i in 0..8 {
xz_dots[i] = gradients[i][0] as f32 * (dx - (i & 1) as f32)
+ gradients[i][2] as f32 * (dz - ((i >> 2) & 1) as f32);
+64
View File
@@ -0,0 +1,64 @@
# Bulk density and noise generation benchmark
The PR dispatches unary and binary density operations once per bulk buffer, resolves the shared Beardifier kernel once per sampled position, and reuses Perlin X-column permutations across the Y loop. Binary bit-exact tests cover every operation, distinct NaN payloads, signed zeros, infinities, subnormals, random float pairs and SIMD/tail-sized buffers. Child-failure tests retain left/right evaluation order and partial output. Scalar shortcuts, arithmetic expressions, RNG consumption and generation traversal are preserved.
## Whole-terrain measurements
**Times below are complete terrain wall elapsed divided by 256 input chunks, with no thread multiplier.** Four-worker figures are elapsed latency/throughput measurements, not per-thread CPU costs. Combined time adds the complete decoration phase, still divided by 256; 196 interior chunks are decorated with unchanged border work. At the primary site, 256 terrain chunks take about 2.578 seconds with one worker versus 0.860 seconds with four: approximately 3.00× throughput, or 75% of ideal fourfold scaling. A subsequent 1/2/4/8-worker scaling experiment is reported below.
Fresh equivalent optimized builds compare baseline `e4f8154cb4115aa1ee622381d9b12387cdf515d4` with the extended candidate. Every case has one discarded process pair, then five measured pairs alternating baseline/candidate order. Initialized processes first generate and discard the same offset 9×9 region at center+(64,64), using the same seeded generator, before timing fresh measured workers. This excludes lazy ring initialization without pre-generating target chunks. All cases use size 16; primary seed/site is 12345/(0,0), second Overworld seed/site is -1/(32,-32).
Medians below are baseline → extended candidate, ms/input chunk, followed by percent reduction.
- **overworld, 1 worker(s):** terrain 12.685400 → 10.069365 (20.62%); combined 14.696298 → 12.105007 (17.63%).
- **overworld, 4 worker(s):** terrain 4.045564 → 3.359536 (16.96%); combined 4.663124 → 3.944952 (15.40%).
- **the_nether, 1 worker(s):** terrain 5.088375 → 4.848149 (4.72%); combined 5.481617 → 5.239165 (4.42%).
- **the_nether, 4 worker(s):** terrain 1.446298 → 1.366468 (5.52%); combined 1.574890 → 1.472913 (6.48%).
- **the_end, 1 worker(s):** terrain 1.085323 → 0.980046 (9.70%); combined 1.161651 → 1.053080 (9.35%).
- **the_end, 4 worker(s):** terrain 0.281733 → 0.259724 (7.81%); combined 0.312280 → 0.288982 (7.46%).
- **overworld, 1 worker(s), second site:** terrain 11.585829 → 9.079823 (21.63%); combined 12.650823 → 10.145760 (19.80%).
- **overworld, 4 worker(s), second site:** terrain 3.105819 → 2.519504 (18.88%); combined 3.410155 → 2.812551 (17.52%).
- **overworld, 1 worker(s), non-initialized generator:** terrain 23.429316 → 20.942006 (10.62%); combined 25.599745 → 23.005476 (10.13%).
The non-initialized case retains lazy startup work and is separate from recurring-cost qualification; resource loading is outside all terrain brackets. All 45 measured terrain pairs improved, but Nether one-worker median terrain improvement remains below 5%. Results are workload-dependent. The primary one-worker noise bracket improves 5.901774 → 4.773963 ms/chunk (19.11%); shared bulk material-density work also improves, with surface 4.576660 → 3.181641 (30.48%). Whole-terrain gains must not be described as noise-stage-only gains. Parallel stage brackets are aggregate worker elapsed and are not exclusive CPU shares.
## Added benefit beyond unary dispatch
A separate five-pair alternating comparison uses the existing unary-only PR revision `594b50278044df6b72b641cd02d5050925c86203` as baseline. It uses the same initialized primary workload and fresh builds. These numbers measure the binary/Beardifier/Perlin additions together; they do not assign a separate speedup to each addition.
- **1 worker(s):** terrain 10.913267 → 10.034900 (8.05%); combined 12.867017 → 12.079432 (6.12%).
- **4 worker(s):** terrain 3.536831 → 3.312338 (6.35%); combined 4.110268 → 3.897104 (5.19%).
All ten incremental terrain pairs improved. Pair reductions ranged 4.72–9.93% with one worker and 2.10–8.61% with four, so not every individual pair exceeds 5%. A preliminary gate was excluded in its entirety because a concurrent Horizon client consumed roughly seven cores. Its raw samples remain in `contended-gate/`; all qualification runs began after the client was closed. No individual samples were selectively removed from the restarted runs.
## Worker scaling follow-up
Candidate revision `c47b30fcf0db87b8023e6784d941a4f06524b453` was tested at 1, 2, 4 and 8 workers on the same primary initialized Overworld workload. The saved `final-candidate` optimized binary is used without rebuilding or changing instrumentation. After one discarded process per worker count, eight measured processes per count run sequentially. Worker orders `[1,2,4,8]`, `[2,8,1,4]`, `[4,1,8,2]`, `[8,4,2,1]` repeat twice, placing each count in each order position twice. Every process initializes its generator using the same offset 9×9 region before measuring 256 terrain chunks and 196 interior decorations. No baseline comparison or new correctness claim is inferred from this scaling experiment.
| Workers | Terrain median ms/chunk (min–max) | Terrain chunks/s | Speedup | Efficiency | Combined median ms/chunk | Combined speedup |
| --- | --- | --- | --- | --- | --- | --- |
| 1 | 9.994644 (9.842544–10.312603) | 100.05 | 1.000× | 100.0% | 11.950737 | 1.000× |
| 2 | 5.580046 (5.499388–5.772284) | 179.21 | 1.791× | 89.6% | 6.644499 | 1.799× |
| 4 | 3.405281 (3.238112–3.525516) | 293.66 | 2.935× | 73.4% | 3.996531 | 2.990× |
| 8 | 2.750915 (2.662450–2.915874) | 363.52 | 3.633× | 45.4% | 3.220818 | 3.710× |
Speedup is the one-worker median divided by the respective median; efficiency divides speedup by worker count. Eight workers give 23.8% more terrain throughput than four workers, with 19.2% lower wall ms/chunk. This is sublinear scaling on this machine and site; eight workers exceed the six physical cores, and this experiment does not identify the causes of diminishing returns. Ordinary desktop activity was not isolated. All 32 measured runs are retained. Raw samples, per-process logs, binary SHA-256, protocol, runnable script and combined ranges are in `/srv/bob-data/horizon-noise-aquifer-e477fa56/extension/scaling/` (`raw.json`, `summary.json`, `protocol.json`, `run.py`). Run with `python /srv/bob-data/horizon-noise-aquifer-e477fa56/extension/scaling/run.py`; the script uses the prepared resources and saved optimized binary, requiring no build. The earlier comparison medians above remain unchanged.
## Machine and validation
AMD Ryzen 5 5600X, 6 cores/12 logical CPUs, 32 GiB RAM, Linux, Rust 1.99.0. Optimized `fast` profile: release optimization, LTO disabled, 16 codegen units. Builds and timed processes were sequential; ordinary desktop activity was not isolated. Primary terrain process CPU medians are 12.4 → 10.0 ms/input chunk (one worker) and 15.9 → 13.2 (four), using coarse 100 Hz accounting. Peak RSS is effectively unchanged: 786288 → 786256 KiB and 833496 → 833528 KiB. No new heap buffer is introduced. Executable text increases 1804 bytes against the original baseline and decreases 1056 bytes against the unary-only revision.
Validation of the extended candidate passed:
- 193 targeted optimized Rust unit/integration tests, including binary floating-point and failure-order tests, density/world fields, storage/palettes, material/carving stages, biome regions, retrogen and ticks.
- Fresh pinned Java client/server density parity: 15,524,627 output lines per side.
- Dedicated noise parity: 1,443,539 lines per side, covering Perlin/smeared bulk paths, strided/wrapped volumes, buffer tails, constructor RNG and derivatives.
- Dedicated Beardifier/structure-density parity: 183 fixtures, 1,360,095 lines per side.
- Terrain-fill parity: 114 fixtures, 200 fills, 7,950,873 lines per side, including prefilled chunks, repeated fills, partial vertical volumes, aquifers, WG heightmaps and ordered postprocessing.
- 24/24 exact region phase comparisons: three dimensions × two seeds/sites × one/four workers, each with 81 retained chunks and 49 interior decorations. Every retained chunk is compared before and after decoration, including borders. Snapshots include raw/public block reads and palettes, quart biomes, entities/block entities as binary NBT, complete scheduled ticks, all six heightmaps, ordered postprocessing, actual non-air counts and chunk metadata. Temporary diagnostic accessors were removed from production source.
This validates the declared corpora and sites, not every possible seed, biome or platform. Lighting, meshing, saving, streaming and full application startup were not benchmarked.
The existing `crates/horizon-world/examples/chunkgen_bench.rs` is the standard workload entry point. Both performance builds used the same saved diagnostic source adding optional generator initialization and exact elapsed/count output; its thread-multiplied human display was not used. Diagnostic builds use `CARGO_TARGET_DIR=/srv/bob-data/horizon-stage3d-target cargo build --profile fast -p horizon-world --example chunkgen_profile`. Raw timings, exact commands, binary/source hashes, scripts and parity outputs are retained outside Git at `/srv/bob-data/horizon-noise-aquifer-e477fa56/extension/`: `gate-raw.json`, `matrix-raw.json`, `summary.json`, `marginal/marginal-raw.json`, `binary-hashes.json`, and the `*-parity.json` reports. Prepared resources are `/srv/bob-data/horizon/.local/horizon-client/26.3`. Generated artifacts and private fixtures remain outside the PR.
The repository quick PR self-check also passes: public-tree validation, workspace rustfmt, workspace/all-target clippy with warnings denied, and 96 full core-crate tests. Relevant pinned Java suites were run separately as listed above. A production-only rebuild after removing diagnostic support has byte-identical executable instructions and read-only constants to the measured candidate.