Skip to content

Thin provisioning support #339

@edubart

Description

@edubart

Context

Some dapps frequently add and remove data from their flash drives. Over time, an active dapp using an on-disk database may consume increasing amounts of drive space on the host without reclaiming free space. This adds unnecessary storage costs for node runners validating the dapp.

This problem can be remediated using thin provisioning. With a proper solution, we could allow machines to start with 1TB of preallocated disk space where the actual used space on the host remains minimal, by leveraging sparse files. The hash tree would remain fast by avoiding pristine data access.

Possible Solutions

The solution requires:

  1. Guest kernel patch: Add support for requesting the host emulator to discard unused disk space (using HTIF device)
  2. Guest filesystem: Mount guest ext4 flash drives with the discard option
  3. Host HTIF device: Handle HTIF request and use hole punching to reclaim space on the host
  4. Hash tree optimization: Ensure the hash tree avoids touching pristine data in memory ranges (e.g., when preallocating a 1TB flash drive)

We should also consider extending this approach to RAM. For machines with 1TB of RAM booted with init_on_alloc=1 init_on_free=1, which zeros allocated/deallocated pages when starting/terminating Linux processes, so we could potentially reclaim space from pristine pages in physical memory as well.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions