CoreyKaylor / Lightning.NET

.NET library for LMDB key-value store
Other
397 stars 82 forks source link

Investigate the value of 0-Copy retrival API #121

Closed AlgorithmsAreCool closed 4 years ago

AlgorithmsAreCool commented 4 years ago

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:

Therefore, someone (probably me) should investigate and measure the performance semantics of this API shape.

CoreyKaylor commented 4 years ago

Probably not needed anymore after https://github.com/CoreyKaylor/Lightning.NET/pull/125