Record each command into the driver's command buffer at the call

Recording at the call replaces the deferred replay, with the pipeline-wait test settling the
device's in-place check that recording at the call made fall inside its run.

One work packet, landed as 2 commits on archive/development-linear-2026-10-29, in order:

* Record each command into the driver's command buffer at the call (6c9d1f4551)

An encoder's command buffers are the driver's VkCommandBuffers from the command
buffer's pool, recorded at each call on the program's thread. The deferral is
gone: the per-command log, the deferred handles, the replays and the recorder
thread, the scheduler's wake of it, the host pages' replay holds, and
WorkCounts::{command_buffers_deferred, command_buffers_replayed,
command_buffers_replayed_inline} (removed public fields; none is read by the
consumer). The slots' routed entry points stay as a counting door:
WorkCounts::commands_replayed counts each command at the call, across every
command buffer (the scheduler's barrier buffers and primaries begun ahead
included, so its totals rise: the drag frame's 1000 -> 1094). A shadow's copy in
over dirty-logged host pages becomes a segment its batch's submission records
(Deferred::GatedCopyIn), so its regions are still decided after the commit's
dirty-log stamp. Rebind re-encode (replay.rs, reencode.rs) is unchanged.
RUNTIME_VERSION 1692.

Verified on the Apple M3 Max (MoltenVK): runtime device suite 1392/1393 twice
(pipeline_wait_order's "a batch waiting for a pipeline holds only the batches
that share its resources" fails under suite load only, a known load flake that
now fails more often; 3/3 alone; the base passed 1395/1395 under the same
load); new recorded_at_the_call::a_fill_is_recorded_at_its_call; the three
dirty_pages_device tests through the gated segment; plain runtime 1145/1145;
conformance plain 1007/1007 (its racy-count test now reads wakes_spared and
command_buffers_submitted); clippy plain and --cfg m2v_gpu; rustdoc.
Release A/B on the M3 (5 interleaved pairs, host load 16-43): drag frame
commit-to-handler p50 3.416 -> 3.386 ms back to back, 4.185 -> 3.671 ms paced
at 60 Hz; encode per draw +7.9% back to back, +15.7% paced (the recording moved
onto the program's thread). Not run: the validation plain suite, the
validation lanes edited, lavapipe; conformance's MoltenVK cost records hold
begin/end/barrier bounds from the narrower count and need re-recording.

* Settle the device's in-place check before the pipeline-wait test frees its no-copy buffer (40c79d69e6)

The test's texture over a no-copy buffer starts the device's check of images
over host pages, whose rounds make internal submissions on the
m2v-in-place-check thread. On MoltenVK freed memory waits for every device-own
submission issued before it went (freed_memory.rs), so a check submission in
flight as the test drops the buffer delays its deallocator
(host_deallocators_delayed 1). That wait is the runtime's documented behaviour;
the unrelated batch holds no reference to the buffer (a temporary backtrace on
the device's internal submissions showed every one from the check thread, none
from barrier buffers, primaries begun ahead or gated copy segments). The test
assumed no other device work was in flight, and recording at the call made the
test about 2.5x faster, so the release fell inside the check's run. The test
now calls settle_in_place_checks (a condition-variable wait, no sleep) before
its work.

Verified on the Apple M3 Max (MoltenVK): with three heavy device tests beside
it, 10/10 pass (5/10 without the settle, each "the deallocator waited for the
import"); alone 5/5; the runtime device suite 1393/1393. Also run there, all
passing: the validation lane device tests record at the call edited
(commands_replayed, detach, hidden_depth, clear_reach, rate_mapped_passes,
frame_costs, and the row_copies/frame_costs_plain measurements).
This commit is contained in:
Anees Iqbal committed 2026-10-29 15:43:49 +02:00
1 parent 5f2c69e087
commit 44d97aaa5e
49 files changed
+415 -3565

No files matched your search

@@ -69,7 +69,6 @@
use super::checks::metal_submissions;
use super::rebound_use::{ReboundAt, ReboundUse, Recording};
use super::{write_fields, CommandBufferShared, Resident, State};
use crate::buffer::HostPages;
use crate::error::{internal, CommandBufferError, Error};
use crate::live_buffers::LiveTable;
use crate::rebind::{SubmittedHolds, Submitting};
@@ -183,11 +182,9 @@ impl Covered {
impl State {
/// As the command buffer commits (its segments recorded): what its commands took is held
/// weakly until its first submission, which lists `listing` again where the list changed.
/// The pages its commands held go to `held`, which its deferred command buffers' replays
/// hold until they are replayed (`recorder`).
pub(super) fn wait_for_submission(&mut self, listing: Listing, held: &mut Vec<Arc<HostPages>>) {
pub(super) fn wait_for_submission(&mut self, listing: Listing) {
for record in &mut self.ended {
record.taken.wait(held);
record.taken.wait();
}
let segments = self
.recorded
@@ -195,7 +192,7 @@ impl State {
.flat_map(|part| part.segments.iter_mut())
.filter_map(|segment| segment.recorded.as_mut());
for done in segments {
done.taken.wait(held);
done.taken.wait();
}
self.listing = Some(listing);
}
@@ -89,7 +89,6 @@ use super::predication::{Event, Predication};
use super::program_objects;
use super::queue::Slot;
use super::rebind::{Holds, SubmittedHolds, Taken};
use super::recorder::{self, Replays};
use super::render::EndInFlight;
use super::replay::Replay;
use super::residency::Residency;
@@ -260,7 +259,7 @@ pub(super) struct CommandBufferShared {
/// where they are every one the pool handed out and it completed, it gives the pool back
/// with none recording (`spares.rs`).
raws_ended: AtomicU64,
/// Its kernel times, apart from the state, which the scheduler holds while it replays and
/// Its kernel times, apart from the state, which the scheduler holds while it records and
/// submits a batch: a read waits for neither (`gpu_time.rs`).
kernel: KernelTimes,
/// Its status as `status` answers it, apart from the state for the same reason: each
@@ -534,9 +533,6 @@ pub(super) struct State {
/// The pool every `VkCommandBuffer` of this command buffer comes from, with those made from
/// it; `None` until the first, and once given back to the device's spares.
pool: Option<CommandPool>,
/// Its encoders' deferred command buffers and their replays, where the device records them
/// so (`recorder`): `None` until the first, and once let go of.
pub(super) replays: Option<Arc<Replays>>,
/// The pool of a predicated loop's check while it records again the work its laying left
/// apart (`rerun.rs`): every `VkCommandBuffer` the command buffer hands out meanwhile comes
/// from it, and goes back to it for the next run again.
@@ -1764,19 +1760,11 @@ impl Drop for CommandBufferShared {
// nothing of its pool is pending. The device's spares keep it (`spares.rs`), which
// release it only with the device. A timestamp slot it still holds goes back with its
// state.
let (pool, replays) = {
let mut state = lock(&self.state);
(state.pool.take(), state.replays.take())
};
let pool = lock(&self.state).pool.take();
if let Some(pool) = pool {
let shared = self.device.shared();
shared.spares.give_command_pool(shared, pool, false);
}
// Its replays end likewise.
if let Some((pool, _)) = replays.and_then(|replays| replays.release(false)) {
let shared = self.device.shared();
shared.spares.give_command_pool(shared, pool, false);
}
}
}
@@ -1810,7 +1798,6 @@ impl CommandBuffer {
called_over_mutable_map: false,
committing: false,
pool: None,
replays: None,
rerun_pool: None,
recorded: Vec::new(),
tail: None,
@@ -2091,12 +2078,12 @@ impl CommandBuffer {
Ok(residency.with_live(live))
}
/// An encoder's primary command buffer: a deferred one where the device records them so
/// (`recorder`), else one from this command buffer's pool, made on first use. The caller holds
/// An encoder's primary command buffer, from this command buffer's pool, made on first use:
/// the encoder records into it at each call, on the program's thread. The caller holds
/// `state` (the pool is externally synchronized).
pub(super) fn allocate_raw(&self, state: &mut State) -> Result<vk::CommandBuffer, Error> {
self.0
.allocate_deferred(state, vk::CommandBufferLevel::PRIMARY)
.allocate_encoder(state, vk::CommandBufferLevel::PRIMARY)
}
/// An encoder's own primary `VkCommandBuffer` from this command buffer's pool, and whether it
@@ -2129,29 +2116,22 @@ impl CommandBuffer {
/// Give up `raw`, a secondary command buffer recording that nothing will execute (a render
/// pass instance its pass replaced or gave up before running it, or the one instance of a
/// pass that changes nothing): a deferred one (`recorder`) is left unended, so its log is
/// never replayed, and goes with the command buffer's release, as one never ended goes; one
/// of this command buffer's pool ends ([`end_raw`](Self::end_raw)), so the pool goes back to
/// the device's spares unreset (`spares.rs`). Nothing executes either, so the GPU does the
/// same work and every byte it writes is the same; a deferred one's replay only cost the
/// recorder's thread a `vkBeginCommandBuffer`, which ANV makes reset the command buffer's
/// whole state, and the commands' recording.
/// pass that changes nothing): it ends ([`end_raw`](Self::end_raw)), so its pool goes back
/// to the device's spares unreset (`spares.rs`). Nothing executes it, so the GPU does the
/// same work and every byte it writes is the same.
///
/// # Safety
/// As [`end_raw`](Self::end_raw)'s, and no command buffer executes `raw`.
pub(super) unsafe fn give_up_raw(&self, raw: vk::CommandBuffer) -> Result<(), vk::Result> {
if recorder::is_deferred(raw) {
return Ok(());
}
// SAFETY: the caller's.
unsafe { self.end_raw(raw) }
}
/// A secondary command buffer (a render encoder's draws), deferred or from this command
/// buffer's pool as [`allocate_raw`](Self::allocate_raw)'s. The caller holds `state`.
/// A secondary command buffer (a render encoder's draws), from this command buffer's pool as
/// [`allocate_raw`](Self::allocate_raw)'s. The caller holds `state`.
pub(super) fn allocate_secondary(&self, state: &mut State) -> Result<vk::CommandBuffer, Error> {
self.0
.allocate_deferred(state, vk::CommandBufferLevel::SECONDARY)
.allocate_encoder(state, vk::CommandBufferLevel::SECONDARY)
}
/// `addScheduledHandler:`: call `handler` once the command buffer is scheduled, on one of the
@@ -2881,18 +2861,10 @@ impl CommandBuffer {
// its last command buffer ended: what lay in pages a detach replaced while an encoder
// held them goes with them (`detach.rs`), and its tail's commands recorded above
// name the views of an attachment recorded inline (`render/inline_first.rs`).
// Its deferred command buffers replay from now on, on the device's recorder thread,
// and hold the pages their commands name until they are replayed; such pages go here
// all the same, replayed first (`Replays::commit`).
match state.replays.clone() {
Some(replays) => drop(replays.commit(device.shared().vk(), |held| {
state.wait_for_submission(listing, held)
})),
None => state.wait_for_submission(listing, &mut Vec::new()),
}
state.wait_for_submission(listing);
// Committed, its commands recorded for good: a rebind of what they used takes
// effect after them (`rebind.rs`); one a host step records holds until completion
// (`steps_hold`). Only once its replays hold the pages, so a rebind finds them held.
// (`steps_hold`).
if steps_hold {
let held = &mut *state;
let kept = held
@@ -3893,8 +3865,7 @@ impl CommandBufferShared {
unsafe fn end_raw(&self, raw: vk::CommandBuffer) -> Result<(), vk::Result> {
// SAFETY: the caller's.
let ended = unsafe { self.device.shared().vk().end_command_buffer(raw) };
// A deferred one is none of its pool's: its replay ends its own (`recorder`).
if ended.is_ok() && !recorder::is_deferred(raw) {
if ended.is_ok() {
self.raws_ended.fetch_add(1, Ordering::Relaxed);
}
ended
@@ -3916,13 +3887,10 @@ impl CommandBufferShared {
}
}
/// An encoder's command buffer of `level`: where the device records them so, a deferred one
/// of its replays, which take a spare pool of the device's for their replays as the first is
/// made (outside a section, where a spare is taken; else the first replay makes one);
/// elsewhere, or once every deferred handle is live, one from this command buffer's pool
/// ([`allocate`](Self::allocate)). One of a predicated loop's check's pool while it records
/// again (`rerun.rs`).
fn allocate_deferred(
/// An encoder's command buffer of `level`, a driver's the encoder records into at each call:
/// one from this command buffer's pool ([`allocate`](Self::allocate)), or one of a
/// predicated loop's check's pool while it records again (`rerun.rs`).
fn allocate_encoder(
&self,
state: &mut State,
level: vk::CommandBufferLevel,
@@ -3930,33 +3898,7 @@ impl CommandBufferShared {
if let Some(pool) = &state.rerun_pool {
return hand_out(&self.device, &mut lock(pool), level);
}
match self.deferred(state, level)? {
Some(raw) => Ok(raw),
None => self.allocate(state, level),
}
}
/// A deferred command buffer of `level` of its replays, where the device records them so and
/// a handle is free (`recorder`); `None` elsewhere.
fn deferred(
&self,
state: &mut State,
level: vk::CommandBufferLevel,
) -> Result<Option<vk::CommandBuffer>, Error> {
let shared = self.device.shared();
let Some(recorder) = shared.recorder() else {
return Ok(None);
};
if state.replays.is_none() {
let family = shared.queue_family_of(self.queue.vk_queue());
let spare = shared.spares.command_pool(shared, family)?;
state.replays = Some(recorder.replays(family, spare));
}
let raw = (state.replays.as_ref()).and_then(|replays| replays.make(level));
if raw.is_some() {
shared.counts.command_buffer_deferred();
}
Ok(raw)
self.allocate(state, level)
}
/// A `VkCommandBuffer` of `level` from this command buffer's pool, made on first use: a
@@ -3972,12 +3914,8 @@ impl CommandBufferShared {
hand_out(&self.device, self.pool(state)?, level)
}
/// [`CommandBuffer::encoder_primary`]: a deferred one where the device records them so, to
/// begin, whose replay takes the primary its replays' pool holds begun ahead (`recorder`).
/// [`CommandBuffer::encoder_primary`].
fn encoder_primary(&self, state: &mut State) -> Result<(vk::CommandBuffer, bool), Error> {
if let Some(raw) = self.deferred(state, vk::CommandBufferLevel::PRIMARY)? {
return Ok((raw, false));
}
if let Some(buffer) = self.pool(state)?.take_begun() {
return Ok((buffer, true));
}
@@ -4611,17 +4549,6 @@ impl CommandBufferShared {
let shared = self.device.shared();
shared.spares.give_command_pool(shared, pool, settled);
}
// Its replays end, any in progress first, and replay nothing more; their pool goes
// back as its own does, and holds the primary begun ahead in its place: its encoders'
// primaries came from it, and only their replays take that primary (`recorder`).
if let Some(replays) = state.replays.take() {
let completed = state.status == CommandBufferStatus::Completed;
if let Some((pool, settled)) = replays.release(completed) {
settled_pool = settled.then_some(pool.raw);
let shared = self.device.shared();
shared.spares.give_command_pool(shared, pool, settled);
}
}
state.unplaced();
parked = state.parked > 0;
}
@@ -54,9 +54,7 @@
use super::rebound_use::Unlogged;
use super::{lock, CommandBuffer, CommandBufferShared, State};
use crate::buffer::HostPages;
use crate::deferred::{Deferred, StepInputs};
use crate::device::functions::Vk;
use crate::encoder::{RecordedSegment, Replayed, ReplayedPart, Segment};
use crate::pipeline::budget::Urgency;
use crate::replay::Replay;
@@ -175,10 +173,9 @@ impl CommandBufferShared {
}
};
// What a refused splice held goes after the lock.
let vk = device.shared().vk();
let spliced_now = {
let mut state = lock(&self.state);
let spliced = state.splice_replay(vk, at, replayed, residency);
let spliced = state.splice_replay(at, replayed, residency);
if let (Ok(()), Some(predication)) = (&spliced, predication) {
state.predication.take_checks(predication);
}
@@ -264,8 +261,7 @@ impl CommandBufferShared {
counts.reencode_refused();
continue;
};
let vk = device.shared().vk();
let put = lock(&self.state).splice_segment(vk, place, recorded, inputs);
let put = lock(&self.state).splice_segment(place, recorded, inputs);
match put {
Ok(()) => counts.segment_recorded_again(),
Err(unspliced) => {
@@ -314,12 +310,9 @@ impl State {
/// `replayed` back, where its place holds other parts than the encoding again's, or a segment
/// but one whose pipelines are being made (which goes, the encoding again having left one of
/// its own in its place) or work its commit recorded on the GPU alone, or its group was
/// submitted, or the
/// command buffer completed. Its replays hold what its commands took with `device`, the
/// device's functions (`Replays::hold`).
/// submitted, or the command buffer completed.
pub(super) fn splice_replay(
&mut self,
device: &Vk,
at: usize,
replayed: Replayed,
residency: Option<Residency>,
@@ -358,21 +351,13 @@ impl State {
heaps,
} = replayed;
// Held weakly until its group's submission, as the commit held what the first recording
// and its segments took, and by its replays until they are replayed: what they held last
// goes here, as it does without them (`Replays::hold`, with `device`, the device's
// functions).
let mut wait = |pages: &mut Vec<Arc<HostPages>>| {
taken.wait(pages);
let segments = (replayed_parts.iter_mut())
.flat_map(|part| part.segments.iter_mut())
.filter_map(|segment| segment.recorded.as_mut());
for done in segments {
done.taken.wait(pages);
}
};
match self.replays.clone() {
Some(replays) => drop(replays.hold(device, wait)),
None => wait(&mut Vec::new()),
// and its segments took.
taken.wait();
let segments = (replayed_parts.iter_mut())
.flat_map(|part| part.segments.iter_mut())
.filter_map(|segment| segment.recorded.as_mut());
for done in segments {
done.taken.wait();
}
let first = self.ended[at].executions.clone();
for (&part, replayed) in parts.iter().zip(replayed_parts) {
@@ -436,15 +421,13 @@ impl State {
/// Put `recorded`, segment `at` of part `part` recorded again on the GPU alone, in its place
/// before the first submission, with `inputs`, what its host step needs now: what its
/// commands took held weakly until the first submission, as the commit holds them (by its
/// replays too, with `device`, the device's functions: `Replays::hold`). What the first
/// commands took held weakly until the first submission, as the commit holds them. What the first
/// recording retained, its executions and its host step's inputs stay retained; its
/// `VkCommandBuffer`s go with the pool unsubmitted, and what its commands took, held weakly,
/// goes. Refused, changing nothing and giving `recorded` and `inputs` back, where the place
/// holds no such segment, or the command buffer was submitted.
pub(super) fn splice_segment(
&mut self,
device: &Vk,
(part, at): (usize, usize),
mut recorded: RecordedSegment,
inputs: StepInputs,
@@ -456,10 +439,7 @@ impl State {
if !fits {
return Err(Box::new((recorded, inputs)));
}
match self.replays.clone() {
Some(replays) => drop(replays.hold(device, |pages| recorded.taken.wait(pages))),
None => recorded.taken.wait(&mut Vec::new()),
}
recorded.taken.wait();
let segment = &mut self.recorded[part].segments[at];
let first = segment.recorded.replace(recorded);
let before = segment.inputs.replace(inputs);
@@ -384,8 +384,7 @@ impl LoopCheck {
}
}
/// Submit `raws` (ended, in order; deferred ones resolved) on `buffer`'s `VkQueue` and wait
/// for them to complete.
/// Submit `raws` (ended, in order) on `buffer`'s `VkQueue` and wait for them to complete.
fn submit(&self, buffer: &CommandBufferShared, raws: &[vk::CommandBuffer]) -> Result<(), Stop> {
let device = &buffer.device;
let Some(busy) = exit_guard::enter() else {
@@ -393,24 +392,12 @@ impl LoopCheck {
};
let shared = device.shared();
let raw = shared.vk();
let mut reals = Vec::with_capacity(raws.len());
for &handle in raws {
// SAFETY: each ended, its command buffer committed (the laying's, its batch submitted,
// which replayed it); inside a section.
match unsafe { crate::recorder::resolve(raw, handle) } {
Ok(real) => reals.push(real),
Err(error) => {
let error = recording_error(device, crate::error::vulkan(error));
return Err(Stop::Failed(error));
}
}
}
// SAFETY: the device's fences, inside a section.
let fence = unsafe { shared.fences.take(raw) }
.map_err(|error| Stop::Failed(submission_error(device, error)))?;
let queue = buffer.queue.vk_queue();
let submits = [vk::SubmitInfo::default().command_buffers(&reals)];
shared.counts.queue_submitted(1, reals.len());
let submits = [vk::SubmitInfo::default().command_buffers(raws)];
shared.counts.queue_submitted(1, raws.len());
// SAFETY: the `VkQueue` is used under its lock; each command buffer was begun to be
// submitted again (the laying's) or recorded for this submission alone (a run again's),
// ended, and is in no pending submission: the laying's batch completed before the check's
@@ -546,18 +546,6 @@ impl CommandBufferShared {
exit_uses.push(image.transition_use());
}
}
// Its encoders' deferred command buffers replayed now, where the recorder's thread has
// not yet (`recorder`), waiting for a replay in progress: before the first work's take,
// which holds the submissions' order until the submission is made, and which a new
// resource's registration waits for where registrations wait for their place
// (`texture/first_move.rs`). A texture made meanwhile so waits for no replay. Each keeps
// its handle as encoded until the submission (below), which finds it replayed.
for buffer in encoders.iter().flat_map(|recorded| &recorded.raws) {
// SAFETY: each ended, and its command buffer committed; inside the scheduler's
// section.
unsafe { crate::recorder::resolve(raw, *buffer) }
.map_err(|error| recording_error(device, crate::error::vulkan(error)))?;
}
// The new resources' first work, before every command (`texture/first_move.rs`), given
// back if the submission is not made. A batch's commands may reach every texture
// unnamed, so it takes every move, those of images bound to host pages among them, whose
@@ -891,16 +879,6 @@ impl CommandBufferShared {
false => work.insert(0, lead),
}
}
// Its deferred command buffers go as their replays (`recorder`), after every check above
// that compares them as encoded: its encoders', replayed before the first work's take
// (above); the barriers recorded since, replayed here where the recorder's thread has
// not yet reached them.
for buffer in work.iter_mut() {
// SAFETY: each ended, and its command buffer committed; inside the scheduler's
// section.
*buffer = unsafe { crate::recorder::resolve(raw, *buffer) }
.map_err(|error| recording_error(device, crate::error::vulkan(error)))?;
}
let mut work_timeline = vk::TimelineSemaphoreSubmitInfo::default()
.wait_semaphore_values(wait_values)
.signal_semaphore_values(work_signal_values);
@@ -1174,8 +1152,10 @@ impl CommandBufferShared {
Ok(buffer)
}
/// Record the scrub segments of encoders `range` (`Deferred::SparseScrub`), which their batch's
/// submission records with the mappings it applied.
/// Record the segments of encoders `range` that their batch's submission records: the
/// scrubs (`Deferred::SparseScrub`), with the mappings it applied, and the gated copies in
/// (`Deferred::GatedCopyIn`), with the regions their logs say changed since the commit's
/// stamp, published by now.
fn record_scrubs(
&self,
state: &mut State,
@@ -1184,19 +1164,34 @@ impl CommandBufferShared {
let mut scrubs = Vec::new();
for (encoder, recorded) in state.recorded[range.clone()].iter().enumerate() {
for (at, segment) in recorded.segments.iter().enumerate() {
if let (Deferred::SparseScrub(scrub), None) = (&segment.work, &segment.recorded) {
scrubs.push((range.start + encoder, at, Arc::clone(scrub)));
let at_submission = matches!(
segment.work,
Deferred::SparseScrub(_) | Deferred::GatedCopyIn(_)
);
if at_submission && segment.recorded.is_none() {
scrubs.push((range.start + encoder, at, segment.work.clone()));
}
}
}
let device = &self.device;
for (encoder, at, scrub) in scrubs {
for (encoder, at, work) in scrubs {
let raw = self.record_raw(state, |state, buffer| {
// SAFETY: the command buffer is recording; the texture is live (its encoder's
// command buffer holds it), in `GENERAL`, and its batch's updates applied.
let held = unsafe { scrub.record(device, buffer) }?;
if !held.is_empty() {
state.retained.push(Box::new(held));
match &work {
// SAFETY: the command buffer is recording; the texture is live (its encoder's
// command buffer holds it), in `GENERAL`, and its batch's updates applied.
Deferred::SparseScrub(scrub) => {
let held = unsafe { scrub.record(device, buffer) }?;
if !held.is_empty() {
state.retained.push(Box::new(held));
}
}
// SAFETY: the command buffer is recording, outside a render pass; the
// shadowed texture is live (its encoder's command buffer holds it), its
// image in `GENERAL`.
Deferred::GatedCopyIn(copy) => unsafe {
copy.record(device.shared().vk(), buffer)
},
_ => {}
}
Ok(())
})?;