-
Notifications
You must be signed in to change notification settings - Fork 712
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
Dynamic storage #517
Comments
Will What about S_LOAD* opcodes that allocate and update the memory dynamically? This way we only need to do a single db read. I.e. Also, what is the imagined usecase for partial reads and writes? If it's used to manage things like a |
Right now, storage is done in 32 byte slots. While the store / read API is simple, for basic objects like a struct, it creates many indexes which have to each be merkalized. This becomes a very costly endeavor.
It would be far simpler to have a storage API that is dynamic, example OPCodes below:
This way if we wanted to store a struct for example, we could just use one STORE operation to do so VS many.
One issue with this is knowing how much memory you will need to allocate for getting values from storage, but we can have something like:
S_STORE key_addr data_ptr data_len
storesMEM[data_ptr, data_len]
bytes to storage slotMEM[key_addr, 32]
S_SIZE dst_reg key_addr
loads size of storage array todst_reg
S_LOAD key_addr dst_addr offset len
copiesSTORAGE[MEM[key_addr, 32]][offset, len]
toMEM[dst_addr, len] S_LOAD_STACK key_addr offset len
allocateslen
bytes of stack space and copiesSTORAGE[MEM[key_addr, 32]][offset, len]
to itS_LOAD_HEAP key_addr offset len
allocateslen
bytes of heap space and copiesSTORAGE[MEM[key_addr, 32]][offset, len]
to itCFE
/ALOC
and are just possible optimizations)Also if we want partial key updates, we could have some of the following operations
S_PARTIAL_WRITE key_addr ptr offset len
copiesMEM[ptr, len]
bytes toSTORAGE[MEM[key_addr, 32]][offset, len]
updating it partially. We could also allow exceeding the length of the original value, allowing this to extend a keyS_TRUNCATE key_addr len
Truncate storage value tolen
bytesS_DUPLICATE key1_addr key2_addr
Duplicate the contents of a storage slot without having to copy in into the vm memoryWe could also have variants of the operations with immediate-encoded length, since those are likely common operations.
The text was updated successfully, but these errors were encountered: