MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / dispatch_to_core

Method dispatch_to_core

nodedb/src/bridge/dispatch.rs:371–418  ·  view source on GitHub ↗

Dispatch a request directly to a specific core by index. Bypasses vShard routing. Used by the checkpoint manager to send checkpoint requests to every core regardless of vShard assignment.

(
        &mut self,
        core_id: usize,
        request: envelope::Request,
    )

Source from the content-addressed store, hash-verified

369 /// Bypasses vShard routing. Used by the checkpoint manager to send
370 /// checkpoint requests to every core regardless of vShard assignment.
371 pub fn dispatch_to_core(
372 &mut self,
373 core_id: usize,
374 request: envelope::Request,
375 ) -> crate::Result<()> {
376 if core_id >= self.cores.len() {
377 return Err(crate::Error::Dispatch {
378 detail: format!("core {core_id} out of range (have {})", self.cores.len()),
379 });
380 }
381
382 let tenant_id = request.tenant_id.as_u64();
383 let req_id = request.request_id.as_u64();
384 let database_id = request.database_id.as_u64();
385 let channel = &mut self.cores[core_id];
386
387 let cls = self.priority_resolver.priority_for(database_id);
388 channel.wfq.set_priority(database_id, cls);
389
390 channel
391 .wfq
392 .try_enqueue(database_id, request)
393 .map_err(|_| crate::Error::Dispatch {
394 detail: format!("core {core_id}: total WFQ capacity exhausted"),
395 })?;
396
397 channel.update_db_pressure(database_id);
398 channel.flush_wfq();
399
400 let util = channel.request_tx.utilization();
401 if let Some(new_state) = channel.backpressure.update(util) {
402 warn!(
403 core_id,
404 utilization = util,
405 state = ?new_state,
406 "backpressure transition"
407 );
408 }
409
410 *self.tenant_inflight.entry(tenant_id).or_insert(0) += 1;
411 self.request_tenant.insert(req_id, tenant_id);
412
413 if let Some(ref notifier) = channel.wake_notifier {
414 notifier.notify();
415 }
416
417 Ok(())
418 }
419
420 /// Maximum SPSC request queue utilization across all cores (0-100).
421 pub fn max_utilization(&self) -> u8 {

Callers 9

run_checkpoint_cycleFunction · 0.80
dispatch_metaFunction · 0.80
delete_asyncFunction · 0.80
broadcast_to_all_coresFunction · 0.80
broadcast_rawFunction · 0.80
query_collection_sizeFunction · 0.80

Calls 12

priority_forMethod · 0.80
set_priorityMethod · 0.80
try_enqueueMethod · 0.80
update_db_pressureMethod · 0.80
flush_wfqMethod · 0.80
entryMethod · 0.80
lenMethod · 0.45
as_u64Method · 0.45
utilizationMethod · 0.45
updateMethod · 0.45
insertMethod · 0.45
notifyMethod · 0.45