Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple benchmark. Spreads.LMDB is not only zero-copy, but zero-…
…allocation as well and is optimized to be zero-overhead (e.g. .NET methods calls inlining). Note that Spreads by default uses latest master on Windows that uses NTDLL API to grow env file on demand during writes, which is a bit slower but allows to set huge env map size and don't care about it later (same as Linux behavior). Therefore writes are marginally slower in Spreads master, but this is not the same native call. Additionally, Spreads API is much more .NET friendly and supports generics and async out of the box. Binaries are prepacked into .NET distribution and do not require any additional steps on Linux. ## Benchmarks summary There are two benchmarks: individual db put/get with a transaction per value and batched benchmark with 10M values per transaction. The first one demonstrates that Spreads.LMDB is zero-allocation and the second one shows mostly .NET overheads of calling the native lib. The MOPS column is million operations per second, GC columns are .NET garbage collection per generation during tests. Using NO_SYNC to focus on wrapper performance and not disk speed. ## Benchmark with LMDB master with NTDLL API **SimpleWriteReadBenchmark**: 10 rounds of appending 10M values and then reading them. Every value in individual transaction. *SimpleWrite/Read 10x1M longs* Case | MOPS | Elapsed | GC0 | GC1 | GC2 | Memory -------------- |--------:|---------:|------:|------:|------:|--------: Spreads Read | 1.13 | 885 ms | 0.0 | 0.0 | 0.0 | 0.006 MB KdSoft Read | 1.08 | 927 ms | 68.0 | 0.0 | 0.0 | 4.011 MB KdSoft Write | 0.08 | 12580 ms | 61.0 | 1.0 | 0.0 | 0.320 MB Spreads Write | 0.08 | 13324 ms | 0.0 | 0.0 | 0.0 | 0.010 MB ## Benchmark using Release branch of LMDB without NTDLL API. This is more relevant to compare .NET wrappers and not different native calls. Repeatable by replacing binary `libspreads_lmdb.dll.compressed` in `lib/out/w64` folder to the one built from LMDB release branch. **SimpleWriteReadBenchmark**: 10 rounds of appending 10M values and then reading them. Every value in individual transaction. *SimpleWrite/Read 10x1M longs* Case | MOPS | Elapsed | GC0 | GC1 | GC2 | Memory -------------- |--------:|---------:|------:|------:|------:|--------: Spreads Read | 1.12 | 896 ms | 0.0 | 0.0 | 0.0 | 0.008 MB KdSoft Read | 1.09 | 920 ms | 68.0 | 0.0 | 0.0 | 4.009 MB Spreads Write | 0.09 | 11763 ms | 0.0 | 0.0 | 0.0 | 0.009 MB KdSoft Write | 0.08 | 12745 ms | 61.0 | 1.0 | 0.0 | 0.321 MB **SimpleWriteReadBatchedBenchmark**: 10M values per transaction. Spreads in 60% faster *SimpleBatchedWrite/Read 10x1M longs* Case | MOPS | Elapsed | GC0 | GC1 | GC2 | Memory -------------- |--------:|---------:|------:|------:|------:|--------: Spreads Read | 7.14 | 140 ms | 0.0 | 0.0 | 0.0 | 0.000 MB Spreads Write | 6.99 | 143 ms | 0.0 | 0.0 | 0.0 | 0.001 MB KdSoft Read | 4.51 | 222 ms | 0.0 | 0.0 | 0.0 | 0.010 MB KdSoft Write | 4.22 | 237 ms | 0.0 | 0.0 | 0.0 | 0.011 MB P.S. Will not compare to original Lightning.NET because they still [use `new byte[]`](https://github.com/CoreyKaylor/Lightning.NET/blob/8a8e5276108ee60c9ea6d9b2679bf8390baf3341/src/LightningDB/Native/ValueStructure.cs#L14) in the new era of `Span<T>`.
- Loading branch information
4085dde
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New numbers: 8f1e464