mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-19 00:10:00 +00:00
Searching files, folders or symbols while a streaming scan indexed a project of more than 2,048 files could freeze the app for good. Queries hold IndexData::read while scanning on the global Rayon pool; the scan parsed on that same pool, took IndexData::read inside parse_found and published (IndexData::write, writer-preferring) mid-pass, so every worker could block on the lock or on the bounded channel while the query waited for a worker. - parse_found no longer locks: the previous content hash is captured during classification, and unchanged-content metadata is refreshed inside publish. - Background indexing and snapshot hydration run on a dedicated INDEX_POOL. - find_files, find_dirs and find_symbols are async commands on the blocking pool, off the main thread. Adds a test with concurrent queries across a 4,600-file scan and an unchanged-content rescan. Co-authored-by: dengliu <5108773+dengliu@users.noreply.github.com>
49 lines
1.7 KiB
Rust
49 lines
1.7 KiB
Rust
//! Tauri runs a command declared without `async` on the main thread, so disk I/O or a
|
|
//! large diff there freezes the window (input, painting, every other IPC call).
|
|
|
|
/// Commands that read or write project files, Local History or `.env` files, diff two
|
|
/// arbitrary texts, or scan the project index in parallel: they must be `async` and do
|
|
/// that work on the blocking pool.
|
|
const OFF_MAIN_THREAD: &[(&str, &[&str])] = &[
|
|
("doc.rs", &["history_list", "history_content"]),
|
|
("nav.rs", &["find_files", "find_dirs", "find_symbols"]),
|
|
(
|
|
"vcs.rs",
|
|
&[
|
|
"vcs_diff_hunks",
|
|
"vcs_shelves",
|
|
"vcs_shelf_delete",
|
|
"vcs_shelf_rename",
|
|
"vcs_shelf_patch",
|
|
"vcs_changelists_load",
|
|
],
|
|
),
|
|
(
|
|
"run.rs",
|
|
&[
|
|
"run_save_configs",
|
|
"run_templates",
|
|
"run_save_templates",
|
|
"run_import_sources",
|
|
"run_import_configs",
|
|
"run_env_files",
|
|
],
|
|
),
|
|
];
|
|
|
|
#[test]
|
|
fn disk_and_diff_commands_stay_off_the_main_thread() {
|
|
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/commands");
|
|
let mut on_main = Vec::new();
|
|
for (file, commands) in OFF_MAIN_THREAD {
|
|
let source = std::fs::read_to_string(dir.join(file)).unwrap();
|
|
for command in *commands {
|
|
assert!(source.contains(&format!("fn {command}(")), "{file} has no command {command}");
|
|
if !source.contains(&format!("pub async fn {command}(")) {
|
|
on_main.push(*command);
|
|
}
|
|
}
|
|
}
|
|
assert!(on_main.is_empty(), "synchronous commands run on the main thread: {on_main:?}");
|
|
}
|