feat: use a separate thread pool for Matcher (and perhaps for all of skim)#961
Conversation
|
This looks really interesting, and I agree it is needed. The only doubt I have is whether we should make it opt-in or opt-out, I think opt-in makes more sense since the wide majority of our users are binary users, not library ones. I'm not an expert on rayon, but maybe we could add the rayon pool as a field of Matcher, and be able to either manually create one and set it or have a |
Running with a separate thread pool should be better for CLI reactivity too?
Pretty certain setting as pub struct App<'a> {
pub thread_pool: Arc<ThreadPool>,
...
} |
|
I prefer having it at app level, as this allows us to still use the global pool if needed, thanks |
f0ce206 to
893848a
Compare
|
The tests are failing because of flakyness in the status display induced by these changes, could you take a look and fix them ? I'm seeing a lot of flaky tests failing up to 5 times, but I generally don't have flakies locally, sometimes just one or 2 failing once, very rarely more. |
Are you sure these test aren't broken? |
|
You need to run them using cargo insta + cargo nextest and the |
|
I guess it may have been my fault when I rebased, sorry about that |
1 similar comment
|
I guess it may have been my fault when I rebased, sorry about that |
I'm just not sure about why/how these tests are failing. The tests are not documented and there is no assertion of what the failure is. Near as I can tell -- the snapshots do not match? Now, my guess is the snapshots are reading at some interstitial/inflight moment. But imagine you want to write to an AtomicUsize once when processing a 4096 chunk, instead of upon each single update. Is there some semantic reason that's wrong? Not as far as I can tell? |
|
I'll try to take a look at the test harness itself, but it'll have to wait. I agree that the tests are a bit opaque, especially when the failures are due to things like the spinner still showing up |
Split `impl Skim` into a generic `impl<Backend> Skim<Backend>` block so that `Skim::init()`, `Skim::start()`, `Skim::tick()`, etc. work with any backend, not just the default CrosstermBackend. New public API on Skim<B>: - `init_tui_with(tui)` – inject a caller-provided TUI (e.g. TestBackend) - `app()` / `app_mut()` – access the application state - `tui_ref()` / `tui_mut()` – access the TUI - `app_and_tui()` – simultaneous mutable access to both (avoids borrow conflicts in render and handle_event calls) - `final_event()` – inspect the quit event TestHarness now wraps `Skim<TestBackend>` and initializes via `Skim::init()` + `Skim::init_tui_with()`, sharing the production init path (theme, reader, command expansion) instead of duplicating it. https://claude.ai/code/session_016PtHKc9YVEpHftDxG5Nger
…s/two_percent into separate_thread_pool
8bb223a to
c50d289
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thank you, the flakies were due to rayon thread allocation subtleties and a small timing issue |
Description of the changes
Use separate thread pool for Matcher. Using the rayon global thread may interfere with apps running in that thread pool and/or effect interactivity.
Maybe able to de-initialize the static MATCHER_THREAD_POOL by using OnceLock, instead of LazyLock, and using take() to return it to a de-initialized state. See: https://doc.rust-lang.org/std/sync/struct.OnceLock.html#method.take