agave_scheduling_utils/handshake/shared.rs
1pub const MAX_WORKERS: usize = 64;
2
3pub(crate) const VERSION: u64 = 1;
4pub(crate) const LOGON_SUCCESS: u8 = 0x01;
5pub(crate) const LOGON_FAILURE: u8 = 0x02;
6pub(crate) const MAX_ALLOCATOR_HANDLES: usize = 128;
7pub(crate) const GLOBAL_ALLOCATORS: usize = 1;
8
9/// The logon message sent by the client to the server.
10#[derive(Debug, Default, Clone, Copy)]
11#[repr(C)]
12pub struct ClientLogon {
13 /// The number of Agave worker threads that will be spawned to handle packing requests.
14 pub worker_count: usize,
15 /// The allocator file size in bytes, this is shared by all allocator handles.
16 pub allocator_size: usize,
17 /// The number of [`rts_alloc::Allocator`] handles the external process is requesting.
18 pub allocator_handles: usize,
19 /// The size of the `tpu_to_pack` queue in bytes.
20 pub tpu_to_pack_size: usize,
21 /// The size of the `progress_tracker` queue in bytes.
22 pub progress_tracker_size: usize,
23 /// The size of the `pack_to_worker` queue in bytes.
24 pub pack_to_worker_size: usize,
25 /// The size of the `worker_to_pack` queue in bytes.
26 pub worker_to_pack_size: usize,
27 // NB: If adding more fields please ensure:
28 // - The fields are zeroable.
29 // - If possible the fields are backwards compatible:
30 // - Added to the end of the struct.
31 // - 0 bytes is valid default (older clients will not have the field and thus send zeroes).
32 // - If not backwards compatible, increment the version counter.
33}
34
35impl ClientLogon {
36 pub fn try_from_bytes(buffer: &[u8]) -> Option<Self> {
37 if buffer.len() != core::mem::size_of::<Self>() {
38 return None;
39 }
40
41 // SAFETY:
42 // - buffer is correctly sized, initialized and readable.
43 // - `Self` is valid for any byte pattern
44 Some(unsafe { core::ptr::read_unaligned(buffer.as_ptr().cast()) })
45 }
46}