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.
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
Benchmark
To comparise the of performance of
local
vsjsonrpc
machines, I tested booting the last release of tools rootfs tanking random roollbacks:This is the result:
Therefore
jsonrpc
is about 13x times faster thanlocal
, the performance for local would be even worse from bigger machines.