RishabhRD / popfix

Neovim lua API for highly extensible popup window
83 stars 3 forks source link

make single execution fuzzy engine faster by using uv_idle_t instead of uv_timer #9

Closed RishabhRD closed 3 years ago

RishabhRD commented 3 years ago

Previously single execution fuzzy engine used uv_timer to partition big sorting job for responsiveness in multiple iterations of the event loop. This not only made the fuzzy engine responsive for big jobs it made the fuzzy engine way faster than other pure lua competitors.

However, this also introduced a significant delay of 1ms between each job. That means if we have a fairly faster sorter, this would not utilize the CPU resources efficiently.

So, instead of having timer_t for partitioning sorting job into multiple iterations, this pull request partitions sorting job into multiple iterations using idle_t that runs in every iteration of the event loop after polling IO.

RishabhRD commented 3 years ago

We are also stopping idle_t when sorting is complete as the presence of idle_t is very CPU intensive.

However, if data is added or prompt text is changed, idle_t again starts. This makes it way more responsive than running idle_t all the time.