HomePhorge

perf: add lua iteration to decrease loops in lua
793b9f8ddd0eUnpublished

Unpublished Commit · Learn More

  • Repository Importing: This repository is still importing.
  • Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

perf: add lua iteration to decrease loops in lua

Move some of the iteration in to loa and access the values by the index
to reduce the number of loops we need todo to get items into teh results
buffer.

Currently the flow is:

  1. Filter and sort the candidates in rust
  2. Convert to a string and pass to lua
  3. Split the string and add them as lines in a buffer in lua

Now the flow is:

  1. Filter and sort the candidates in rust
  2. Loop over an iterator in lua
  3. Pass each item to lua as a pointer by the index

This removes quite a bit of the work that is needed to get the data into
lua as a table. We are first removing the loop that will join the
results vector into one string. Then we will remove the copy of this
string into lua. We will then finally remove the loop to split the
string and create a table from it in lua. All of this ends up in a 12%
speed up.

Output for ./scripts/bench 0.x

Benchmark 1: HEAD

Time (mean ± σ):      2.667 s ±  0.065 s    [User: 8.537 s, System: 1.420 s]
Range (min … max):    2.588 s …  2.767 s    10 runs

Benchmark 2: 0.x

Time (mean ± σ):      2.337 s ±  0.150 s    [User: 9.564 s, System: 1.648 s]
Range (min … max):    2.161 s …  2.529 s    10 runs

Summary

HEAD ran
  1.14 ± 0.08 times faster than 0.x

The percentage difference is -12.00%

Details

Provenance
AdeAttwoodAuthored on Oct 22 2023, 5:02 PM
Parents
R1:d707a6e15be5: chore: add bench script to benchmark two commits
Branches
Unknown
Tags
Unknown

Event Timeline