As a Block Node Operator
I want to reduce the number of system calls needed to persist a single block
So that I can minimize operating costs.
This task is to change block persistence to persist the blocks as whole files rather than directories of files per item.
Notes:
Currently we have a interface BlockWriter<V> that is writing block items as files inside a directory with the number of the block, this causes multiple (potentially) thousands of system calls per block, slowing down the whole system (does it? Are system calls actually expensive or are we just assuming they are?).
Current and only implementation BlockAsDirWriter was meant to support development and help on debugging by making it easy to see the block items as they are arriving, however due to the high TPS needed for the system, we want to create an additionalBlockAsFileWriter implementation of BlockWriter<List<BlockItem>> to provide more performant support for production purposes.
Considerations:
Do not pre-emptively attempt to fix file permissions. (this only creates more system calls that are completely not needed), instead if there is a IO issue, attempt to fix permissions (in case is that) before retrying and continuing.
Don't set file permissions too permissive, however, it's bad practice and dangerous to have folders or files writable by other processes. Set appropriate umask up front and ensure files are created with appropriate permissions.
keep block items in memory until you receive a Block Proof, then persist to disk (perhaps after verification, perhaps before).
Holding items in memory is less reliable, so we should be careful to ensure, data is reliable, that the storage of in-memory items is not in the wrong component, and data is not duplicated unnecessarily.
We should be holding byte arrays mostly (not parsed items), and only parsing just enough to complete verification.
As a Block Node Operator I want to reduce the number of system calls needed to persist a single block So that I can minimize operating costs.
This task is to change block persistence to persist the blocks as whole files rather than directories of files per item.
Notes:
Currently we have a
interface BlockWriter<V>
that is writing block items as files inside a directory with the number of the block, this causes multiple (potentially) thousands of system calls per block, slowing down the whole system (does it? Are system calls actually expensive or are we just assuming they are?).Current and only implementation
BlockAsDirWriter
was meant to support development and help on debugging by making it easy to see the block items as they are arriving, however due to the high TPS needed for the system, we want to create an additionalBlockAsFileWriter
implementation ofBlockWriter<List<BlockItem>>
to provide more performant support for production purposes.Considerations:
fix
file permissions. (this only creates more system calls that are completely not needed), instead if there is a IO issue, attempt to fix permissions (in case is that) before retrying and continuing.