Commit e75e77b
perf(devices): optimize memory allocations in virtio hot paths
Reduce heap allocations in performance-critical virtio device processing:
1. vsock_windows.rs:
- Use fixed 4KB stack buffer instead of Vec in harvest_stream_reads
- Eliminates heap allocation on every stream read iteration
2. net_windows.rs:
- Use stack array for virtio-net header (was Vec)
- Pre-allocate frame_data with 1500-byte capacity (typical MTU)
- Remove unnecessary descriptor collection (iterate directly)
- Remove unused DescriptorChain import
These changes reduce allocator pressure in the TX/RX hot paths without
changing behavior. All WHPX tests pass.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 9d61ea0 commit e75e77b
2 files changed
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
| 186 | + | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | | - | |
191 | | - | |
| 190 | + | |
192 | 191 | | |
193 | 192 | | |
194 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
550 | | - | |
551 | | - | |
| 551 | + | |
| 552 | + | |
552 | 553 | | |
553 | 554 | | |
554 | 555 | | |
| |||
0 commit comments