Cysharp / MasterMemory

Embedded Typed Readonly In-Memory Document Database for .NET and Unity.
MIT License
1.52k stars 110 forks source link

Add Parallel option to improve database construct performance, Add DISABLE symbols to generated code for reduce code size #76

Closed neuecc closed 2 years ago

neuecc commented 2 years ago

When invoking new MemoryDatabase(byte[] databaseBinary...), read and construct database from binary. If binary size is large then construct performance will slow down. MemoryDatabase has ctor(..., int maxDegreeOfParallelism = 1) option in constructor to construct in parallel.

var database = new MemoryDatabase(bin, maxDegreeOfParallelism: Environment.ProcessorCount);

The use of Parallel can greatly improve the construct performance. Recommend to use Environment.ProcessorCount.

If you want to reduce code size of generated code, Validator and MetaDatabase info can omit in runtime. Generated code has two symbols DISABLE_MASTERMEMORY_VALIDATOR and DISABLE_MASTERMEMORY_METADATABASE. By defining them, can be erased from the build code.