Performance improvements
Hi, here are a few improvements I discovered while working on Metabase.
The first commit addresses the following issue. Binding dynamic variables is comparatively quite expensive. `honey.sql/format` binds a lot of dynvars, but most of them usually don't receive meaningful values. A different approach is possible – prepare a bindings map that would contain only the vars with values that actually have changed, and pass that to `with-bindings` macro. Here are ad-hoc benchmark results obtained from Metabase tests:
```
Before
Time per call: 228.36 ms Alloc per call: 559,342,831b
Time per call: 224.91 ms Alloc per call: 559,342,813b
Time per call: 228.88 ms Alloc per call: 559,342,813b
After
Time per call: 205.92 ms Alloc per call: 452,848,231b
Time per call: 202.64 ms Alloc per call: 452,848,232b
Time per call: 205.16 ms Alloc per call: 452,848,229b
```
So, -20% allocations and -10% execution time.
The second commit ensures that `xs` passed to `format-values` is a vector because this function traverses `xs` multiple times using reduce, and the latter is inefficient for arbitrary seqs. The commit also contains a few minor changes that swap lazy seq processing for transducers.
合并状态:未合并 5 条评论