summaryrefslogtreecommitdiff
path: root/src/lsp/Scip.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 11:30:01 -0300
committerGabriel Schneider <[email protected]>2026-11-11 18:57:59 -0300
commitfc38c73c59f7855a4caad8aa4d3bb8e023309c13 (patch)
tree20088bf9099c48fd3dcbc4d38c6eb1b7c6b3a1c8 /src/lsp/Scip.zig
parent1497cf19f852a5b38bc3e2f3641a81a077ba8a32 (diff)
downloadpardes-main.tar.gz
pardes-main.zip
scip: support 512 MiB workspace indexes with lazy bounded storageHEADmain
Raise both index and lookup-table budgets to 512 MiB so the 104 MiB Agave index fits. Allocate the two cache regions on first use to avoid oversized static storage, and propagate allocation failures. Update the documented limits. Verified nine language-backend tests, native addon checks, and the live Agave index (1,117 documents and 156,866 symbols).
Diffstat (limited to 'src/lsp/Scip.zig')
-rw-r--r--src/lsp/Scip.zig21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/lsp/Scip.zig b/src/lsp/Scip.zig
index 3d3cc648..540ba5cd 100644
--- a/src/lsp/Scip.zig
+++ b/src/lsp/Scip.zig
@@ -16,12 +16,10 @@
const std = @import("std");
const statPath = @import("../fs.zig").statPath;
-/// One loaded index's caps, measured on a real one: rust-analyzer 1.97's
-/// index of clap_builder 4.6.7 (29 kloc) is 3.9 MB, with 55 documents,
-/// 32,795 occurrences and 6,661 symbols, and its tables take 3.1 MB; these
-/// hold eight times that. A bigger index is refused, in words.
-pub const max_bytes = 32 << 20;
-const tables_bytes = 32 << 20;
+/// Agave's workspace index is 104 MiB; leave room for it and its lookup tables.
+/// A bigger index is refused, in words.
+pub const max_bytes = 512 << 20;
+const tables_bytes = 512 << 20;
/// Indexes kept loaded at once, the one asked least recently replaced.
const kept = 2;
@@ -202,11 +200,12 @@ fn rangeOf(bytes: []const u8, typed: enum { packed_ints, single, multi }) error{
// ------------------------------------------------------------------ loading
-var regions: [kept][max_bytes + tables_bytes]u8 align(std.heap.page_size_max) = @splat(@splat(0));
+// Keep the large bounded regions out of the executable's static address range.
+var regions: [kept]?[]u8 = @splat(null);
var slots: [kept]Index = @splat(.{});
var clock: u64 = 0;
-pub const Error = error{ TooBig, Malformed, Unreadable };
+pub const Error = error{ TooBig, Malformed, Unreadable, OutOfMemory };
/// The index for a file in `dir`: the nearest `index.scip` there or up to
/// seven directories above, read again when it changed since; null with
@@ -237,7 +236,11 @@ fn use(io: std.Io, p: []const u8, st: std.Io.File.Stat) Error!*Index {
ix.* = .{ .mtime = st.mtime.nanoseconds, .size = st.size, .used = clock, .path_len = p.len };
@memcpy(ix.path_buf[0..p.len], p);
errdefer ix.* = .{};
- const region = &regions[pick];
+ const region = regions[pick] orelse blk: {
+ const memory = try std.heap.page_allocator.alloc(u8, max_bytes + tables_bytes);
+ regions[pick] = memory;
+ break :blk memory;
+ };
const file = std.Io.Dir.cwd().openFile(io, p, .{}) catch return error.Unreadable;
defer file.close(io);
const got = file.readPositionalAll(io, region[0..@intCast(st.size)], 0) catch return error.Unreadable;