fix: move file type guessing out of project_manager thread

Performing hundreds of thousands of file type guessing operations can
block the project manager for seconds leading to slow exits. With this
change we move the file type guessing into the tree walker thread leaving
the project manager to respond to other requests including shutdown messages.
This commit is contained in:
CJ van den Berg 2025-10-02 17:43:12 +02:00
parent e7dcb2947b
commit 6301c078c8
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 31 additions and 12 deletions

View file

@ -318,8 +318,6 @@ const Process = struct {
var method: []const u8 = undefined;
var cbor_id: []const u8 = undefined;
var params_cb: []const u8 = undefined;
var high: i64 = 0;
var low: i64 = 0;
var max: usize = 0;
var row: usize = 0;
var col: usize = 0;
@ -338,10 +336,9 @@ const Process = struct {
var eol_mode: Buffer.EolModeTag = @intFromEnum(Buffer.EolMode.lf);
if (try cbor.match(m.buf, .{ "walk_tree_entry", tp.extract(&project_directory), tp.extract(&path), tp.extract(&high), tp.extract(&low) })) {
const mtime = (@as(i128, @intCast(high)) << 64) | @as(i128, @intCast(low));
if (try cbor.match(m.buf, .{ "walk_tree_entry", tp.extract(&project_directory), tp.more })) {
if (self.projects.get(project_directory)) |project|
project.walk_tree_entry(path, mtime) catch |e| self.logger.err("walk_tree_entry", e);
project.walk_tree_entry(m) catch |e| self.logger.err("walk_tree_entry", e);
} else if (try cbor.match(m.buf, .{ "walk_tree_done", tp.extract(&project_directory) })) {
if (self.projects.get(project_directory)) |project|
project.walk_tree_done(self.parent.ref()) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;