Skip to main content

JACOBIAN_BATCH_MIN_PROBLEMS

Constant JACOBIAN_BATCH_MIN_PROBLEMS 

Source
pub const JACOBIAN_BATCH_MIN_PROBLEMS: usize = 256;
Expand description

Lane count below which a ComputeBackend::CpuMulti request runs jacobian_batch on the calling thread instead.

§Measured crossover

Methodology. Same machine, date, build and load as DERIVATIVE_BATCH_MIN_POINTS — 4 logical cores, load average 2.3-3.6, not idle. n = 4 Jacobians, DiffSettings::central so each lane costs 8 evaluations of a 4-component function, best of 7, two independent runs. Produced by the same #[ignore]d differentiate_crossover_benchmark test.

Lanescheap serialcheap speed-up (A)(B)costly speed-up (A)(B)
41.56 us0.19x0.16x0.21x0.21x
83.05 us0.10x0.12x0.63x0.35x
166.05 us0.19x0.21x0.60x0.65x
3212.06 us0.83x0.33x1.52x1.03x
6423.64 us0.57x0.70x1.18x2.18x
12848.36 us0.84x1.34x1.86x2.46x
25695.16 us1.09x1.11x1.88x2.61x
1 024373.05 us1.63x2.18x1.86x1.50x
4 0961590.74 us1.75x1.90x1.85x3.10x
16 3846702.36 us1.83x2.98x2.06x2.88x

Result. 256 — the smallest lane count that won in both runs. It lands on exactly the same value as crate::math::minimise::MINIMISE_BATCH_MIN_PROBLEMS and crate::math::parallel::ROOT_BATCH_MIN_PROBLEMS, and 256x below this module’s own DERIVATIVE_BATCH_MIN_POINTS. The two numbers in one module disagreeing by 256x is the clearest evidence yet for the point crate::compute::CPU_MULTI_MIN_WORK_ITEMS makes: the crossover tracks work per lane, not the algorithm. A Jacobian lane here does 8 function evaluations, four vector allocations and a matrix assembly; a scalar derivative lane does 2 evaluations and a division.

§A performance trap found by this measurement, recorded so it is not reintroduced

The first version of the central-difference column copied the point twice per column (x.to_vec() for the +h probe and again for the -h probe). With that version the parallel path never won at any size measured, topping out at 0.96x on 16 384 lanes — allocation traffic, not arithmetic, was the whole cost. Reusing a single probe buffer made the serial path ~1.4x faster and restored parallel scaling to 1.8-3.0x. If a future change reintroduces a per-column allocation, this crossover is the measurement that will notice.

§Limitations

As for DERIVATIVE_BATCH_MIN_POINTS, plus: measured at n = 4 only. A larger n raises the per-lane cost and should lower this crossover, but that has not been measured.

§Units

A count of independent Jacobian problems, dimensionless.