implement MappedPageBox - #2688
Conversation
There was a problem hiding this comment.
Benchmark Results
Details
| Benchmark | Current: afb2fd0 | Previous: 2e23902 | Performance Ratio |
|---|---|---|---|
| startup_benchmark Build Time | 94.88 s |
80.34 s |
1.18 ❗ |
| startup_benchmark File Size | 0.79 MB |
0.80 MB |
0.99 ❗ |
| Startup Time - 1 core | 0.72 s (±0.01 s) |
0.75 s (±0.02 s) |
0.97 ❗ |
| Startup Time - 2 cores | 0.73 s (±0.02 s) |
0.74 s (±0.02 s) |
0.99 |
| Startup Time - 4 cores | 0.75 s (±0.02 s) |
0.74 s (±0.02 s) |
1.02 |
| multithreaded_benchmark Build Time | 97.09 s |
82.11 s |
1.18 ❗ |
| multithreaded_benchmark File Size | 0.88 MB |
0.86 MB |
1.03 ❗ |
| Multithreaded Pi Efficiency - 2 Threads | 66.38 % (±7.07 %) |
85.89 % (±6.61 %) |
0.77 ❗ |
| Multithreaded Pi Efficiency - 4 Threads | 40.77 % (±3.21 %) |
43.43 % (±2.56 %) |
0.94 |
| Multithreaded Pi Efficiency - 8 Threads | 20.25 % (±1.62 %) |
25.76 % (±1.53 %) |
0.79 ❗ |
| micro_benchmarks Build Time | 228.86 s |
80.40 s |
2.85 ❗ |
| micro_benchmarks File Size | 0.88 MB |
0.86 MB |
1.03 ❗ |
| Scheduling time - 1 thread | 181.75 ticks (±34.28 ticks) |
62.65 ticks (±4.06 ticks) |
2.90 ❗ |
| Scheduling time - 2 threads | 112.33 ticks (±19.87 ticks) |
34.08 ticks (±4.10 ticks) |
3.30 ❗ |
| Micro - Time for syscall (getpid) | 9.79 ticks (±5.47 ticks) |
3.45 ticks (±0.58 ticks) |
2.84 ❗ |
| Memcpy speed - (built_in) block size 4096 | 54954.16 MByte/s (±39455.21 MByte/s) |
82448.38 MByte/s (±56997.13 MByte/s) |
0.67 |
| Memcpy speed - (built_in) block size 1048576 | 13800.55 MByte/s (±11052.06 MByte/s) |
30585.98 MByte/s (±24707.84 MByte/s) |
0.45 |
| Memcpy speed - (built_in) block size 16777216 | 11602.18 MByte/s (±9567.56 MByte/s) |
26340.06 MByte/s (±21720.96 MByte/s) |
0.44 |
| Memset speed - (built_in) block size 4096 | 55175.27 MByte/s (±39573.39 MByte/s) |
82292.76 MByte/s (±56891.50 MByte/s) |
0.67 |
| Memset speed - (built_in) block size 1048576 | 14141.22 MByte/s (±11220.95 MByte/s) |
31323.85 MByte/s (±25145.86 MByte/s) |
0.45 |
| Memset speed - (built_in) block size 16777216 | 11914.80 MByte/s (±9749.06 MByte/s) |
27104.68 MByte/s (±22209.94 MByte/s) |
0.44 |
| Memcpy speed - (rust) block size 4096 | 52099.50 MByte/s (±37357.42 MByte/s) |
74097.96 MByte/s (±51811.44 MByte/s) |
0.70 |
| Memcpy speed - (rust) block size 1048576 | 15099.14 MByte/s (±13302.15 MByte/s) |
30361.60 MByte/s (±24602.37 MByte/s) |
0.50 |
| Memcpy speed - (rust) block size 16777216 | 12266.05 MByte/s (±10429.45 MByte/s) |
27625.34 MByte/s (±22806.88 MByte/s) |
0.44 |
| Memset speed - (rust) block size 4096 | 52678.43 MByte/s (±37705.76 MByte/s) |
74373.47 MByte/s (±51976.48 MByte/s) |
0.71 |
| Memset speed - (rust) block size 1048576 | 15352.60 MByte/s (±13395.62 MByte/s) |
31110.89 MByte/s (±25033.24 MByte/s) |
0.49 |
| Memset speed - (rust) block size 16777216 | 12627.38 MByte/s (±10644.62 MByte/s) |
28386.93 MByte/s (±23265.03 MByte/s) |
0.44 |
| alloc_benchmarks Build Time | 218.77 s |
74.76 s |
2.93 ❗ |
| alloc_benchmarks File Size | 0.87 MB |
0.87 MB |
0.99 ❗ |
| Allocations - Allocation success | 91.38 % |
91.31 % |
1.00 ❗ |
| Allocations - Deallocation success | 100.00 % |
100.00 % |
1 |
| Allocations - Pre-fail Allocations | 61.60 % |
61.44 % |
1.00 ❗ |
| Allocations - Average Allocation time | 16115.33 Ticks (±3060.92 Ticks) |
5860.58 Ticks (±98.43 Ticks) |
2.75 ❗ |
| Allocations - Average Allocation time (no fail) | 17985.55 Ticks (±3036.26 Ticks) |
6554.81 Ticks (±92.86 Ticks) |
2.74 ❗ |
| Allocations - Average Deallocation time | 7625.61 Ticks (±1503.91 Ticks) |
1805.01 Ticks (±250.35 Ticks) |
4.22 ❗ |
| mutex_benchmark Build Time | 228.32 s |
79.82 s |
2.86 ❗ |
| mutex_benchmark File Size | 0.88 MB |
0.86 MB |
1.03 ❗ |
| Mutex Stress Test Average Time per Iteration - 1 Threads | 36.20 ns (±8.62 ns) |
12.10 ns (±0.41 ns) |
2.99 ❗ |
| Mutex Stress Test Average Time per Iteration - 2 Threads | 31.36 ns (±9.11 ns) |
40.26 ns (±1.68 ns) |
0.78 |
This comment was automatically generated by workflow using github-action-benchmark.
mkroening
left a comment
There was a problem hiding this comment.
Thanks! Did you use any AI assistance? :)
| // `paging::unmap` only flushes the TLB of this CPU. Request the flush on | ||
| // all other CPUs before the frames can be reused. | ||
| #[cfg(all(target_arch = "x86_64", feature = "smp"))] | ||
| crate::arch::kernel::apic::ipi_tlb_flush(); |
There was a problem hiding this comment.
This seems costly. Is this necessary? We do an IPI TLB flush on mapping after all.
There was a problem hiding this comment.
will see how i can come with a better drop
There was a problem hiding this comment.
@mkroening I removed the call now. But the ipi sent on mapping flushes TLB on other cpus only if the entry is present in the page table. since we delete the entry on unmap, stale TLB can still remains on other cpus.
| impl Deref for MappedPageBox { | ||
| type Target = PageRange; | ||
|
|
||
| fn deref(&self) -> &Self::Target { | ||
| &self.pages | ||
| } | ||
| } |
There was a problem hiding this comment.
This seems non-obvious to me, since there are two types of ranges inside. If we need something like this, I'd prefer accessor methods.
| fn page_count(pages: &PageBox) -> usize { | ||
| pages.len().get() / BasePageSize::SIZE as usize | ||
| } |
There was a problem hiding this comment.
Please remove this helper function.
| fn map(pages: &PageBox, phys_addr: PhysAddr, flags: PageTableEntryFlags) { | ||
| paging::map::<BasePageSize>( | ||
| VirtAddr::from(pages.start()), | ||
| phys_addr, | ||
| page_count(pages), | ||
| flags, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Please remove this helper function.
yeah i am clearing unwanted stuff it added here! |
d3ab508 to
afb2fd0
Compare
mkroening
left a comment
There was a problem hiding this comment.
Thanks, this looks good to me. One more suggestion, though.
| }) | ||
| } | ||
|
|
||
| pub fn pages(&self) -> &PageBox { |
There was a problem hiding this comment.
| pub fn pages(&self) -> &PageBox { | |
| pub fn pages(&self) -> &PageRange { |
Closes #2338
Added MappedPageBox and used it in two call sites.
Also removed
#[expect(dead_code)]in src/arch/aarch64/mm/paging.rs because new public API makes it externally reachable.