Issue #116 offered 'option 3' as a way to potentially allow faster access to large keys by avoiding the implicit copy of the other Get methods.
Proposed API Shape
public class Transaction
{
public bool TryGet(LightningDatabase db, ReadOnlySpan<byte> key, TArg arg, ReadOnlySpanAction<byte, TArg> inspector);
}
Discussion
Unfortunately, the proposed API shape is tricky to understand and while generally safe, is even trickier to use in a way that offers optimal performance. To use correctly you need to provide a delegate that, at minimum, follows these rules:
[PERF] Ensure your passed delegate isn't being re-allocated each call
[PERF] Ensure your delegate doesn't block or waste time. This can delay a pending write transaction.
[SAFETY] Ensure you do not try to store the Span itself outside of the scope of the transaction.
Therefore, someone (probably me) should investigate and measure the performance semantics of this API shape.
Issue #116 offered 'option 3' as a way to potentially allow faster access to large keys by avoiding the implicit copy of the other Get methods.
Proposed API Shape
Discussion
Unfortunately, the proposed API shape is tricky to understand and while generally safe, is even trickier to use in a way that offers optimal performance. To use correctly you need to provide a delegate that, at minimum, follows these rules:
Therefore, someone (probably me) should investigate and measure the performance semantics of this API shape.