Skip to content

Use probe-rs MemoryInterface::read() to make reads go faster - #722

Merged
jamesmunns merged 4 commits into
masterfrom
james/probe-go-faster
Aug 7, 2026
Merged

Use probe-rs MemoryInterface::read() to make reads go faster#722
jamesmunns merged 4 commits into
masterfrom
james/probe-go-faster

Conversation

@jamesmunns

Copy link
Copy Markdown
Contributor

As a follow-up to #721, we realized that probe-rs changes have made read_u8 actually do u8 reads, which makes our bulk reading operations roughly 4x slower.

This switches to the new MemoryInterface::read() API, which does word-size reads (with some potential over-/under-reading), which we believe matches the old read_8 behavior.

This has a noticable speed improvement for flash --verify:

jamesmunns@lurch ~ $ humility --version
humility 0.12.18 
jamesmunns@lurch ~ $ time pfexec humility -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp flash --verify
humility: WARNING: archive on command-line overriding archive in environment file
humility: attaching with chip set to "STM32H753ZITx"
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP
humility: verified 563.50 KiB in 11 seconds
humility: verified auxflash in slot 2
humility flash failed: archive is already flashed on attached device; use -F ("--force") to force re-flash

real    0m12.621s
user    0m3.926s
sys     0m1.307s

# master pre-#721
jamesmunns@lurch ~ $ time pfexec ./humility-0807 -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp flash --verify
humility: WARNING: archive on command-line overriding archive in environment file
humility: attaching with chip set to "STM32H753ZITx"
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP V2 IF: 4 DESC: Some(InterfaceAltSetting { interface_number: 4, alternate_setting: 0, num_endpoints: 2, class: 255, subclass: 0, protocol: 0, string_index: Some(9), endpoints: [Endpoint { address: 0x05, direction: Out, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }, Endpoint { address: 0x85, direction: In, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }] })
humility: verifying 577024 bytes at 0x8000000
humility: verified 563.50 KiB in 42 seconds
humility: verified auxflash in slot 2
humility flash failed: archive is already flashed on attached device; use -F ("--force") to force re-flash

real    0m44.414s
user    0m5.487s
sys     0m3.616s

# master post-#721
jamesmunns@lurch ~ $ time pfexec ./humility-0807-fast -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp flash --verify
humility: WARNING: archive on command-line overriding archive in environment file
humility: attaching with chip set to "STM32H753ZITx"
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP V2 IF: 4 DESC: Some(InterfaceAltSetting { interface_number: 4, alternate_setting: 0, num_endpoints: 2, class: 255, subclass: 0, protocol: 0, string_index: Some(9), endpoints: [Endpoint { address: 0x05, direction: Out, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }, Endpoint { address: 0x85, direction: In, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }] })
humility: verifying 577024 bytes at 0x8000000
humility: verified 563.50 KiB in 22 seconds
humility: verified auxflash in slot 2
humility flash failed: archive is already flashed on attached device; use -F ("--force") to force re-flash

real    0m24.510s
user    0m5.394s
sys     0m3.575s

# this branch
jamesmunns@lurch ~ $ time pfexec ./humility-0807-faster -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp flash --verify
humility: WARNING: archive on command-line overriding archive in environment file
humility: attaching with chip set to "STM32H753ZITx"
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP V2 IF: 4 DESC: Some(InterfaceAltSetting { interface_number: 4, alternate_setting: 0, num_endpoints: 2, class: 255, subclass: 0, protocol: 0, string_index: Some(9), endpoints: [Endpoint { address: 0x05, direction: Out, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }, Endpoint { address: 0x85, direction: In, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }] })
humility: verifying 577024 bytes at 0x8000000
humility: verified 563.50 KiB in 7 seconds
humility: verified auxflash in slot 2
humility flash failed: archive is already flashed on attached device; use -F ("--force") to force re-flash

real    0m8.589s
user    0m3.683s
sys     0m1.295s

As well as for dump:

# 0.12.18
jamesmunns@lurch ~ $ time pfexec humility -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp dump
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP
humility: core halted
humility: dumping to "hubris.core.0"
humility: dumped 910.38 KiB in 17 seconds
humility: core resumed

real    0m19.461s
user    0m4.488s
sys     0m2.048s

# master pre-#721
jamesmunns@lurch ~ $ time pfexec ./humility-0807 -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp dump
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP V2 IF: 4 DESC: Some(InterfaceAltSetting { interface_number: 4, alternate_setting: 0, num_endpoints: 2, class: 255, subclass: 0, protocol: 0, string_index: Some(9), endpoints: [Endpoint { address: 0x05, direction: Out, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }, Endpoint { address: 0x85, direction: In, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }] })
humility: core halted
humility: dumping to "hubris.core.1"
humility: dumped 910.38 KiB in 68 seconds
humility: core resumed

real    1m11.501s
user    0m7.066s
sys     0m5.829s

# master post-#721
jamesmunns@lurch ~ $ time pfexec ./humility-0807-fast -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp dump
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP V2 IF: 4 DESC: Some(InterfaceAltSetting { interface_number: 4, alternate_setting: 0, num_endpoints: 2, class: 255, subclass: 0, protocol: 0, string_index: Some(9), endpoints: [Endpoint { address: 0x05, direction: Out, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }, Endpoint { address: 0x85, direction: In, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }] })
humility: core halted
humility: dumping to "hubris.core.2"
humility: dumped 910.38 KiB in 36 seconds
humility: core resumed

real    0m39.589s
user    0m7.174s
sys     0m5.780s

# this branch
jamesmunns@lurch ~ $ time pfexec ./humility-0807-faster -a ./build-grapefruit-a-image-default-master.zip -t grapefruit-sp dump
humility: WARNING: archive on command-line overriding archive in environment file
humility: attached to 0d28:0204:00000080488fa31e569f0cd2389b3d90c84efe104c504355 via CMSIS-DAP V2 IF: 4 DESC: Some(InterfaceAltSetting { interface_number: 4, alternate_setting: 0, num_endpoints: 2, class: 255, subclass: 0, protocol: 0, string_index: Some(9), endpoints: [Endpoint { address: 0x05, direction: Out, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }, Endpoint { address: 0x85, direction: In, transfer_type: Bulk, max_packet_size: 512, packets_per_microframe: 1, interval: 0 }] })
humility: core halted
humility: dumping to "hubris.core.3"
humility: dumped 910.38 KiB in 11 seconds
humility: core resumed

real    0m13.785s
user    0m4.221s
sys     0m2.043s

@jamesmunns
jamesmunns requested a review from labbott August 7, 2026 13:51

@labbott labbott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments but LGTM. I think this is relatively low risk since arguably we are going back to the behavior we had before (and there's zero change to the net behavior)

Comment thread humility-probes-core/src/probe_rs.rs
Comment thread cmd/readmem/src/lib.rs Outdated
@jamesmunns
jamesmunns enabled auto-merge (squash) August 7, 2026 15:08
@jamesmunns
jamesmunns merged commit 80dae8d into master Aug 7, 2026
13 checks passed
@jamesmunns
jamesmunns deleted the james/probe-go-faster branch August 7, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants