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

Function spawn_core

nodedb/src/data/runtime.rs:166–379  ·  view source on GitHub ↗
(
    core_id: usize,
    request_rx: Consumer<BridgeRequest>,
    response_tx: Producer<BridgeResponse>,
    data_dir: &Path,
    wal_records: Arc<[nodedb_wal::WalRecord]>,
    tombstones: nodedb_wal

Source from the content-addressed store, hash-verified

164
165#[allow(clippy::too_many_arguments)]
166pub fn spawn_core(
167 core_id: usize,
168 request_rx: Consumer<BridgeRequest>,
169 response_tx: Producer<BridgeResponse>,
170 data_dir: &Path,
171 wal_records: Arc<[nodedb_wal::WalRecord]>,
172 tombstones: nodedb_wal::TombstoneSet,
173 num_cores: usize,
174 compaction_config: CoreCompactionConfig,
175 system_metrics: Option<Arc<crate::control::metrics::SystemMetrics>>,
176 event_producer: Option<crate::event::bus::EventProducer>,
177 governor: Arc<nodedb_mem::MemoryGovernor>,
178 quiesce: Option<Arc<crate::bridge::quiesce::CollectionQuiesce>>,
179 hlc: Arc<nodedb_types::OrdinalClock>,
180 array_catalog: crate::control::array_catalog::ArrayCatalogHandle,
181 quarantine_registry: Arc<crate::storage::quarantine::QuarantineRegistry>,
182 maintenance_budget: Arc<crate::control::maintenance::MaintenanceBudgetTracker>,
183) -> std::io::Result<(JoinHandle<()>, EventFdNotifier)> {
184 let data_dir = data_dir.to_path_buf();
185
186 // Create eventfd and extract notifier before moving EventFd to core thread.
187 let efd = EventFd::new().map_err(std::io::Error::other)?;
188 let notifier = efd.notifier();
189
190 let handle = std::thread::Builder::new()
191 .name(format!("data-core-{core_id}"))
192 .spawn(move || {
193 // 1. Pin to dedicated jemalloc arena.
194 match nodedb_mem::arena::pin_thread_arena(core_id as u32) {
195 Ok(arena) => info!(core_id, arena, "pinned to jemalloc arena"),
196 Err(e) => warn!(core_id, error = %e, "failed to pin jemalloc arena, continuing with default"),
197 }
198
199 // 2. Open engines.
200 let mut core = CoreLoop::open_with_array_catalog(
201 core_id,
202 request_rx,
203 response_tx,
204 &data_dir,
205 hlc,
206 array_catalog,
207 )
208 .expect("failed to open CoreLoop engines");
209
210 // 2b. Apply memory governor.
211 core.set_governor(governor);
212 core.set_maintenance_budget(maintenance_budget);
213
214 // 2b. Apply metrics reference.
215 if let Some(m) = system_metrics {
216 core.set_metrics(m);
217 }
218
219 // 2b. Wire Event Plane producer (Data Plane → Event Plane).
220 if let Some(ep) = event_producer {
221 core.set_event_producer(ep);
222 }
223

Callers 1

spawn_data_plane_coresFunction · 0.85

Calls 15

pin_thread_arenaFunction · 0.85
nowFunction · 0.85
drain_and_rejectFunction · 0.85
panic_messageFunction · 0.85
notifierMethod · 0.80
set_event_producerMethod · 0.80
set_quiesceMethod · 0.80
set_compaction_configMethod · 0.80
set_query_tuningMethod · 0.80

Tested by

no test coverage detected