cornucopia icon indicating copy to clipboard operation
cornucopia copied to clipboard

Optimising codegen using an asynchronous client and pipelining

Open Virgiel opened this issue 2 years ago • 1 comments

When benchmarking codegen, I found that we spent most of our time communicating with the database synchronously to prepare each query one by one. By using an asynchronous client and relying on pipelining, codegen's time went from 22ms to 6ms on my machine.

Virgiel avatar May 24 '23 23:05 Virgiel

When we generate code against a managed database, most of our time is spent on docker commands, 1.3s when managed vs 50ms when live. We don't have an easy way to improve this.

Parsing is also an expensive CPU task that we can parallelize by module, but the gain is less: 6ms down to 4ms. Finally, we could also use mmap instead of reading queries and schema files into memory for even smaller but easy gain.

Virgiel avatar May 25 '23 07:05 Virgiel