Skip to content

10x-100x Compilation speed boost

Choose a tag to compare
@marcgrue marcgrue released this 25 Oct 19:04
· 437 commits to master since this release

The core macro transformation engine has been re-written from the ground up and micro-optimizations applied wherever possible. This has resulted in dramatic compilation speed improvements, some several orders of magnitude!

Macro materialization of molecules earlier produced a lot of code that has now been moved out to static methods. An absolute minimal amount of code is now generated, thus minimizing the job of the macros and the compiler. As an example, the Seattle tests file sometimes took up to 70 seconds to compile and now average around 4 seconds. Some long molecules with close to 22 attributes almost never finished compiling but now take about 2 seconds to compile! This is good news since users of Molecule can therefore now freely create as large molecules as they please without any speed penalty.

5 optimized getter groups

Type casting of returned data from Datomic was earlier not completely optimized. Taking advice from
Haoyi's "Benchmarking Scala Collections"
Molecule now also returns super fast mutable pre-allocated Arrays of typed data for large data sets.

Json has also been thoroughly optimized to build as fast as possible directly from raw Datomic data.

So Molecule now offers 5 optimized getter groups:

  • get - Default List of typed tuples for convenient access to smaller data sets.
  • getArray - Array of typed tuples for fast retrieval and traversing of large data sets.
  • getIterable - Iterable of typed tuples for lazy evaluation of data
  • getJson - Json formatted result data
  • getRaw - Raw untyped data from Datomic

Each getter group comes with all time-related variations:

  • get
  • getAsOf(t)
  • getSince(t)
  • getWith(txData)
  • getHistory (only implemented for List getter)