~crc_/retroforth#10: 
python: implement copy on write

Splitting from #8:

given its python it would also be useful to implement memory as copy on write. the constructor for the class would be given the ngaImage as an array of integers. memory for the vm is however a dictionary of addresses that have been written to. reads are first checked against the changed memory, falling back to the array for the default value.

Status
REPORTED
Submitter
~crc_
Assigned to
No-one
Submitted
8 months ago
Updated
2 months ago
Labels
2021.7 vm

~crc_ 8 months ago

Things to do to make this work:

  • add a dictionary for the copy-on-write
  • update i_st() to update this
  • update i_fe() to check this and select either the raw memory or the dictionary value
  • update findEntry(), i_li(), extractString(), injectString(), execute(), run() to check both memory areas

For this, we should add a functions for handling this and use them, to make overall maintenance and remove what would otherwise be unneeded duplications.

~crc_ 8 months ago

RFC: What are the primary advantages / disadvantages of this?

I'm not a Python developer; while I do use Python, I'm far from being an expert in it, and have no real idea of the tradeoffs involved.

~scott91e1 8 months ago

runtime overhead during memory access and additional code traded for:

  • instant startup allowing arrays of hundreds (thousands++) of VMs at near zero cost

  • lower overall memory use where base image is baked into the source code

  • allows unbounded growth on demand as the memory size is not fixed at startup

  • freeze/restore state is more efficient as only changed memory and registers are copied

~crc_ referenced this from #8 6 months ago

~crc_ referenced this from #36 5 months ago

~crc_ referenced this from #56 2 months ago

Register here or Log in to comment, or comment via email.