Skip to content

perf: enable demand paging for heap (3 GiB → 654 MiB snapshots) - #100

Closed
danbugs wants to merge 1 commit into
chore/rebase-hyperlight-depfrom
perf/demand-page-heap
Closed

perf: enable demand paging for heap (3 GiB → 654 MiB snapshots)#100
danbugs wants to merge 1 commit into
chore/rebase-hyperlight-depfrom
perf/demand-page-heap

Conversation

@danbugs

@danbugs danbugs commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Points all examples at danbugs/unikraft:perf/demand-page-heap, which adds a uk_paging_page_unmap call in boot.c:heap_init() to tear down boot-provided identity-mapped PTEs after setting up the demand-paged VMA
  • Hyperlight's Snapshot::from_env() identity-maps the entire heap in boot page tables before the guest starts. Unikraft's uk_vma_map_anon creates a demand-paged VMA on top but never removes the existing PTEs, so vma_op_anon_fault never fires and all heap pages (including untouched zeroes) end up in the snapshot
  • The fix unmaps the boot PTEs for the heap remainder (keeping 16 bootstrap pages), letting the VMA fault handler re-map pages on first access — only touched pages carry PTEs
  • Python snapshot shrinks from 3.0 GiB to 654 MiB (1 zero page remaining vs ~600K before)

Test plan

  • CI passes for all 18 examples with the fork branch
  • Validate snapshot sizes are reduced for Python guests

@danbugs
danbugs force-pushed the perf/demand-page-heap branch from 4383532 to da91188 Compare June 24, 2026 17:39

@github-actions github-actions Bot 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.

Linux Benchmarks

Details
Benchmark suite Current: 307f19b Previous: 4460ae2 Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 110 ms 110 ms 1
density (per VM) 8 MB 11 MB 0.73
snapshot (disk) 653 MiB 656 MiB 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Temporarily point all examples' unikraft source at
danbugs/unikraft:perf/demand-page-heap to validate the
boot.c heap unmap fix across all examples.

This branch adds a uk_paging_page_unmap call after
uk_vma_map_anon in heap_init(), tearing down boot-provided
identity-mapped PTEs so demand paging works correctly.
Reduces snapshot size from 3.0 GiB to 654 MiB for Python
guests.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs
danbugs force-pushed the perf/demand-page-heap branch from da91188 to 307f19b Compare June 24, 2026 17:55
@danbugs
danbugs changed the base branch from main to chore/rebase-hyperlight-dep June 24, 2026 17:55

@github-actions github-actions Bot 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.

Windows Benchmarks

Details
Benchmark suite Current: 307f19b Previous: 4460ae2 Ratio
hello_world (median) 151 ms 301 ms 0.50
pandas (median) 546 ms 768 ms 0.71
density (per VM) 328 MB 656 MB 0.50
snapshot (disk) 654 MiB 664 MiB 0.98

This comment was automatically generated by workflow using github-action-benchmark.

@danbugs

danbugs commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

No longer needed — demand-page-heap testing covered in PR 99

@danbugs danbugs closed this Jun 25, 2026
@danbugs
danbugs deleted the perf/demand-page-heap branch June 29, 2026 16:44
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.

1 participant