pub struct AsupersyncConfig {
pub max_decode_attempts: u32,
pub max_repair_symbols: u32,
pub max_transfer_ms: u64,
pub capabilities: CapabilitySet,
}Fields§
§max_decode_attempts: u32§max_repair_symbols: u32§max_transfer_ms: u64§capabilities: CapabilitySetImplementations§
Source§impl AsupersyncConfig
impl AsupersyncConfig
Sourcepub fn with_capabilities(self, capabilities: CapabilitySet) -> Self
pub fn with_capabilities(self, capabilities: CapabilitySet) -> Self
Examples found in repository?
examples/transport_receive_ab.rs (line 268)
230fn main() {
231 let payload_bytes: usize = 64 * 1024;
232 // Sized for signal, not for wall-clock: on rch nearly all of this example's
233 // runtime is COMPILING the asupersync dependency tree, so the measurement
234 // phase is effectively free and there is no reason to under-sample. At 400
235 // receives x 16 rounds the A/A null came in at 1.0853x on vmi1152480, which
236 // is too loose to sit under a 1.8x claim on a busy shared host.
237 let receives_per_thread: usize = 2_000;
238 let rounds: usize = 32;
239 // NOT CACHED, and correctly so (br-frankenpandas-q1evw): this sizes the A/B
240 // harness's worker count ONCE at startup, so the cgroup walk is paid a single
241 // time for the whole process rather than per call. The per-call cache that
242 // `fp_columnar::cached_available_parallelism` provides has nothing to win here.
243 let threads = std::thread::available_parallelism()
244 .map(std::num::NonZeroUsize::get)
245 .unwrap_or(4)
246 .min(8);
247
248 let config = AsupersyncConfig::default();
249 let shipped = InMemoryTransport::new();
250 shipped
251 .send(artifact(payload_bytes), &config)
252 .expect("seed shipped transport");
253 let legacy = LegacyInMemoryTransport::default();
254 legacy.store(artifact(payload_bytes), &config);
255
256 // PARITY BEFORE TIMING. A faster arm that returns something different is not
257 // a faster arm, and the bead requires the error surfaces to be preserved.
258 let a = shipped
259 .receive(ARTIFACT_ID, &config)
260 .expect("shipped receive");
261 let b = legacy
262 .receive(ARTIFACT_ID, &config)
263 .expect("legacy receive");
264 assert_eq!(a.artifact_id, b.artifact_id, "parity: artifact_id");
265 assert_eq!(a.source_len, b.source_len, "parity: source_len");
266 assert_eq!(a.repair_symbols, b.repair_symbols, "parity: repair_symbols");
267 assert_eq!(a.encoded_bytes, b.encoded_bytes, "parity: encoded_bytes");
268 let denied = AsupersyncConfig::default().with_capabilities(CapabilitySet::default());
269 assert!(
270 shipped.receive(ARTIFACT_ID, &denied).is_err(),
271 "parity: shipped must refuse a denied capability set"
272 );
273 assert!(
274 legacy.receive(ARTIFACT_ID, &denied).is_err(),
275 "parity: legacy control must refuse the same way"
276 );
277 assert!(
278 shipped.receive("no-such-artifact", &config).is_err(),
279 "parity: missing artifact must still error"
280 );
281 assert!(
282 legacy.receive("no-such-artifact", &config).is_err(),
283 "parity: legacy control must error the same way"
284 );
285
286 let control = Control {
287 start: Barrier::new(threads + 1),
288 finish: Barrier::new(threads + 1),
289 arm: AtomicUsize::new(ARM_SHIPPED),
290 active: AtomicUsize::new(threads),
291 receives: AtomicUsize::new(receives_per_thread),
292 stop: AtomicBool::new(false),
293 };
294
295 let mut ab_shipped: Vec<Duration> = Vec::new();
296 let mut ab_legacy: Vec<Duration> = Vec::new();
297 let mut null_leader: Vec<Duration> = Vec::new();
298 let mut null_follower: Vec<Duration> = Vec::new();
299 let mut seq_shipped: Vec<Duration> = Vec::new();
300 let mut seq_legacy: Vec<Duration> = Vec::new();
301
302 std::thread::scope(|scope| {
303 for worker in 0..threads {
304 let control = &control;
305 let shipped = &shipped;
306 let legacy = &legacy;
307 let config = &config;
308 scope.spawn(move || {
309 loop {
310 control.start.wait();
311 if control.stop.load(Ordering::SeqCst) {
312 break;
313 }
314 if worker < control.active.load(Ordering::SeqCst) {
315 let arm = control.arm.load(Ordering::SeqCst);
316 let receives = control.receives.load(Ordering::SeqCst);
317 let mut checksum: u64 = 0;
318 for _ in 0..receives {
319 let got = if arm == ARM_SHIPPED {
320 shipped.receive(ARTIFACT_ID, config)
321 } else {
322 legacy.receive(ARTIFACT_ID, config)
323 }
324 .expect("receive must succeed");
325 // Consume the result so neither arm can be optimized
326 // away, and both pay the same read cost.
327 checksum = checksum
328 .wrapping_add(u64::from(got.encoded_bytes[0]))
329 .wrapping_add(u64::from(
330 got.encoded_bytes[got.encoded_bytes.len() - 1],
331 ))
332 .wrapping_add(got.source_len as u64);
333 }
334 std::hint::black_box(checksum);
335 }
336 control.finish.wait();
337 }
338 });
339 }
340
341 // Warm both arms so the first timed round does not pay page-fault and
342 // allocator-growth costs that belong to neither.
343 for _ in 0..3 {
344 time_unit(&control, Arm::Shipped, threads, receives_per_thread);
345 time_unit(&control, Arm::Legacy, threads, receives_per_thread);
346 }
347
348 for round in 0..rounds {
349 // BALANCED SQUARE: the leader alternates, so each arm occupies each
350 // slot equally across any pair of rounds.
351 let (lead, follow) = if round % 2 == 0 {
352 (Arm::Shipped, Arm::Legacy)
353 } else {
354 (Arm::Legacy, Arm::Shipped)
355 };
356 let order = [lead, follow, follow, lead];
357 let mut slots = [Duration::ZERO; 4];
358 for (slot, arm) in order.iter().enumerate() {
359 slots[slot] = time_unit(&control, *arm, threads, receives_per_thread);
360 }
361 let (lead_ns, follow_ns) = score_square(&slots);
362 let lead_dur = Duration::from_nanos(lead_ns as u64);
363 let follow_dur = Duration::from_nanos(follow_ns as u64);
364 match lead {
365 Arm::Shipped => {
366 ab_shipped.push(lead_dur);
367 ab_legacy.push(follow_dur);
368 }
369 Arm::Legacy => {
370 ab_legacy.push(lead_dur);
371 ab_shipped.push(follow_dur);
372 }
373 }
374
375 // A/A NULL THROUGH THE IDENTICAL SQUARE: four runs of the SHIPPED
376 // arm, scored exactly as above. This asks what the DESIGN reports
377 // when the two arms are the same code, which is the only thing a
378 // null can legitimately certify.
379 let mut null_slots = [Duration::ZERO; 4];
380 for slot in &mut null_slots {
381 *slot = time_unit(&control, Arm::Shipped, threads, receives_per_thread);
382 }
383 let (null_lead_ns, null_follow_ns) = score_square(&null_slots);
384 null_leader.push(Duration::from_nanos(null_lead_ns as u64));
385 null_follower.push(Duration::from_nanos(null_follow_ns as u64));
386
387 // SEQUENTIAL NEGATIVE CONTROL: one worker, no contention, same
388 // square. The lever only moves work out of a CONTENDED critical
389 // section, so this should land near 1.0.
390 let seq_order = [lead, follow, follow, lead];
391 let mut seq_slots = [Duration::ZERO; 4];
392 for (slot, arm) in seq_order.iter().enumerate() {
393 seq_slots[slot] = time_unit(&control, *arm, 1, receives_per_thread);
394 }
395 let (seq_lead_ns, seq_follow_ns) = score_square(&seq_slots);
396 let seq_lead = Duration::from_nanos(seq_lead_ns as u64);
397 let seq_follow = Duration::from_nanos(seq_follow_ns as u64);
398 match lead {
399 Arm::Shipped => {
400 seq_shipped.push(seq_lead);
401 seq_legacy.push(seq_follow);
402 }
403 Arm::Legacy => {
404 seq_legacy.push(seq_lead);
405 seq_shipped.push(seq_follow);
406 }
407 }
408 }
409
410 control.stop.store(true, Ordering::SeqCst);
411 control.start.wait();
412 });
413
414 let shipped_ns = median_ns(ab_shipped);
415 let legacy_ns = median_ns(ab_legacy);
416 let null_ratio = median_ns(null_follower) / median_ns(null_leader);
417 let seq_ratio = median_ns(seq_legacy) / median_ns(seq_shipped);
418 let ratio = legacy_ns / shipped_ns;
419
420 println!("=== br-frankenpandas-3nzz3 InMemoryTransport::receive A/B ===");
421 println!("harness : crates/fp-runtime/examples/transport_receive_ab.rs");
422 println!("harness_sha256 : {}", harness_sha256());
423 println!(
424 "worker : {}",
425 std::env::var("RCH_WORKER").unwrap_or_else(|_| read_trimmed("/proc/sys/kernel/hostname"))
426 );
427 println!(
428 "hostname : {}",
429 read_trimmed("/proc/sys/kernel/hostname")
430 );
431 println!("threads_used : {threads}");
432 // PROVENANCE SITE, DELIBERATELY NOT CACHED (br-frankenpandas-q1evw): the row
433 // records the live parallelism of the host that produced this A/B.
434 println!(
435 "available_parallel : {:?}",
436 std::thread::available_parallelism().map(std::num::NonZeroUsize::get)
437 );
438 println!(
439 "governor : {}",
440 read_trimmed("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor")
441 );
442 println!("isa : {}", isa_summary());
443 println!("profile : release");
444 println!(
445 "shape : payload={payload_bytes}B receives/thread={receives_per_thread} rounds={rounds}"
446 );
447 println!("design : balanced square ABBA/BAAB, pool spawned once, same invocation");
448 println!("---");
449 println!("A/A null ratio : {null_ratio:.4}x (same code both sides; must be near 1.0)");
450 println!("sequential control : {seq_ratio:.4}x (1 thread; lever should NOT show here)");
451 println!("---");
452 println!("shipped (Arc) : {:.3} ms median", shipped_ns / 1.0e6);
453 println!("legacy (control) : {:.3} ms median", legacy_ns / 1.0e6);
454 println!("RATIO legacy/shipped: {ratio:.4}x (>1 means the shipped lever is faster)");
455}Trait Implementations§
Source§impl Clone for AsupersyncConfig
impl Clone for AsupersyncConfig
Source§impl Debug for AsupersyncConfig
impl Debug for AsupersyncConfig
Source§impl Default for AsupersyncConfig
impl Default for AsupersyncConfig
Source§impl<'de> Deserialize<'de> for AsupersyncConfig
impl<'de> Deserialize<'de> for AsupersyncConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for AsupersyncConfig
Source§impl PartialEq for AsupersyncConfig
impl PartialEq for AsupersyncConfig
Source§impl Serialize for AsupersyncConfig
impl Serialize for AsupersyncConfig
impl StructuralPartialEq for AsupersyncConfig
Auto Trait Implementations§
impl Freeze for AsupersyncConfig
impl RefUnwindSafe for AsupersyncConfig
impl Send for AsupersyncConfig
impl Sync for AsupersyncConfig
impl Unpin for AsupersyncConfig
impl UnsafeUnpin for AsupersyncConfig
impl UnwindSafe for AsupersyncConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).