Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Make OverseerRun faster #335

Closed
1 task done
rmenai opened this issue Aug 1, 2024 · 1 comment
Closed
1 task done

feature request: Make OverseerRun faster #335

rmenai opened this issue Aug 1, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@rmenai
Copy link

rmenai commented Aug 1, 2024

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

There should be an option to cache the output of the OverseerRun command on file load and when changing buffers. This would make the command much faster and much better to use, especially when mapping it to a shortcut.

Provide background

When running OverseerRun command, it takes a lot of time because it needs to parse the builtin templates and then check the conditions of each template. It would be nice to make this command faster because right now, it takes like 2 seconds to run for me.

What is the significance of this feature?

strongly desired

Additional details

Here is the part of the code where all the work is done

for _, provider in ipairs(providers) do
  local provider_name = provider.name
  local is_match, message = condition_matches(provider.condition, nil, opts, false) -- THIS TAKES SO MUCH TIME
  if is_match then
    local cache_key = provider.cache_key(opts)
    local provider_cb = function(tmpls)
      handle_tmpls(tmpls, provider_name, provider.module, cache_key)
    end
    start_times[provider.name] = vim.loop.hrtime()  -- Undefined field `hrtime`.
    pending[provider.name] = true
    if cache_key and cached_provider_results[cache_key] then
      handle_tmpls(
        cached_provider_results[cache_key],
        provider_name,
        provider.module,
        cache_key,
        true
      )
    else
      local ok, tmpls = pcall(provider.generator, opts, provider_cb)
      if ok then
        if tmpls then
          -- if there was a return value, the generator completed synchronously
          -- TODO deprecate this flow
          provider_cb(tmpls)
        end
      else
        log:error("Template provider %s: %s", provider.name, tmpls)
      end
    end
  else
    report.providers[provider_name] = {
      is_present = is_match,
      message = message,
      total_tasks = 0,
      available_tasks = 0,
    }
  end
end

No response

@rmenai rmenai added the enhancement New feature or request label Aug 1, 2024
@rmenai
Copy link
Author

rmenai commented Aug 1, 2024

After digging more into this, I nailed down the issue to vim.fn.executable taking a long time to run on WSL..

I ended up fixing this by changing this setting on WSL and in worked! Now it loads instantly

@rmenai rmenai closed this as completed Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant