You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current Flush and dynamic storage has problems in that dynamically allocated storage entities cannot be properly deallocated from storage because of a missing global accessor to the dynamic storage allocator as well as a missing accessor to the flusher.
We have to fix both problems while maintaining the efficiency gains through the new ink_core::env2.
Global Instance
The only solution I currently see is that we introduce a globally accesible object that handles dynamic storage allocations and deallocations. This is a major move from the internal DynEnv approach that we have right now that tightly encapsulates the dynamic environment which enables us to perfectly reuse our internal buffers to avoid many (re-)allocations on the heap. However, this system does not allow access from anywhere and requires to have references from anywhere in order to allow for generic and ubiquitous operations such as deallocation (Drop) and flushing (through Flush trait).
Buffer Pool
In order to maintain efficiency a solution might be to introduce a global buffer pool that is accessible from anywhere through shared references (&self) and enables buffer reusing. It is basically a pool of buffers that allow for intermediate buffer usages from anywhere to avoid heap allocations.
A possible interface for this could be:
/// Returns a reference to a shared buffer./// Shared buffers are generally a `Vec<u8>` under the hood and allow to store intermediate results./// When such a `SharedBuffer` is dropped (through its `Drop`) impl it is returned back to the `BufferPool` for later reuse.fnget_buffer(&self) -> SharedBuffer;
The major problem is what the exact lifetime of such a returned SharedBuffer shall be optimally. We don't want them to be stored anywhere for an extended period of time since they are generally meant to be used as intermediate buffers. So we should attach some lifetime to them in the way how RefCell does that through RefMut etc.
The text was updated successfully, but these errors were encountered:
The #311 introduced a new dynamic storage allocator that actually works. The only thing left is a follow-up to introduce and use a so-called PushOnDrop abstractions but the rest already works as expected for the new storage2 module. Closed.
The current
Flush
and dynamic storage has problems in that dynamically allocated storage entities cannot be properly deallocated from storage because of a missing global accessor to the dynamic storage allocator as well as a missing accessor to the flusher.We have to fix both problems while maintaining the efficiency gains through the new
ink_core::env2
.Global Instance
The only solution I currently see is that we introduce a globally accesible object that handles dynamic storage allocations and deallocations. This is a major move from the internal
DynEnv
approach that we have right now that tightly encapsulates the dynamic environment which enables us to perfectly reuse our internal buffers to avoid many (re-)allocations on the heap. However, this system does not allow access from anywhere and requires to have references from anywhere in order to allow for generic and ubiquitous operations such as deallocation (Drop
) and flushing (throughFlush
trait).Buffer Pool
In order to maintain efficiency a solution might be to introduce a global buffer pool that is accessible from anywhere through shared references (
&self
) and enables buffer reusing. It is basically a pool of buffers that allow for intermediate buffer usages from anywhere to avoid heap allocations.A possible interface for this could be:
The major problem is what the exact lifetime of such a returned
SharedBuffer
shall be optimally. We don't want them to be stored anywhere for an extended period of time since they are generally meant to be used as intermediate buffers. So we should attach some lifetime to them in the way howRefCell
does that throughRefMut
etc.The text was updated successfully, but these errors were encountered: