Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for snapshot/rollback in local machines #237

Closed
wants to merge 1 commit into from

Conversation

edubart
Copy link
Contributor

@edubart edubart commented Apr 29, 2024

This is an experimental PR adding support for performing snapshot/rollback on local machines. Making the APIs available in Windows and WASM. It uses the naive implementation of duplicating the whole machine memory.

This PR does not try to optimize this operation to compete with JSONRPC fork(), it just provides the naive implementation that will work on any system.

TODO

  • add lua tests
  • make deep copy of merkle tree and use it
  • avoid deep copy of read only PMAs and design a way to share them between multiple machines
    • introduce read only flash drives, so we can avoid copying them, useful for machines with read-only rootfs
  • optimize Windows memory map to not use calloc
  • add disable CMIO option again, so we don't have to deep copy them on WASM
  • add fork method to machine C API?

Benchmark

To comparise the of performance of local vs jsonrpc machines, I tested booting the last release of tools rootfs tanking random roollbacks:

math.randomseed(0)
while not machine:read_iflags_H() do
    machine:snapshot()
    machine:run(machine:read_mcycle() + 1000)
    if math.random() < 0.3 then
        machine:rollback()
    else
        machine:commit()
    end
end

This is the result:

local       67 iterations/s
jsonrpc    895 iterations/s

Therefore jsonrpc is about 13x times faster than local, the performance for local would be even worse from bigger machines.

@edubart edubart added the enhancement New feature or request label Apr 29, 2024
@edubart edubart self-assigned this Apr 29, 2024
@edubart edubart changed the base branch from main to fix/jsonrpc-shutdown-rebind April 29, 2024 19:33
Base automatically changed from fix/jsonrpc-shutdown-rebind to main April 30, 2024 10:19
@edubart
Copy link
Contributor Author

edubart commented Oct 10, 2024

This PR is being superseded by #281 , which will be superior and faster.

@edubart edubart closed this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant