summaryrefslogtreecommitdiff
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
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).
-rw-r--r--docs/lsp-evaluation.md2
-rw-r--r--docs/typ/setup.typ2
-rw-r--r--src/lsp/Scip.zig21
3 files changed, 14 insertions, 11 deletions
diff --git a/docs/lsp-evaluation.md b/docs/lsp-evaluation.md
index b98ea4c0..8f7c0266 100644
--- a/docs/lsp-evaluation.md
+++ b/docs/lsp-evaluation.md
@@ -133,7 +133,7 @@ nearest `index.scip` above the file (SCIP, scip-code.org: a protobuf file
an indexer writes at the project's root) before any server:
`src/lsp/Scip.zig` reads it, about 350 lines with its tests, keeping each
document's occurrences and each symbol's information in a fixed region
-(an index of 32 MB at most, its tables 32 MB, two indexes at once). Def,
+(an index of 512 MiB at most, its tables 512 MiB, two indexes at once). Def,
type definition, Refs, SelectRefs, `gi`, Subtypes, Supertypes, Symbols,
WsSymbols, Hover, Callers, Callees and the Callstack tree answer from it
where it knows the symbol: locally, with no handshake and no index to
diff --git a/docs/typ/setup.typ b/docs/typ/setup.typ
index b25175b4..2a10c52c 100644
--- a/docs/typ/setup.typ
+++ b/docs/typ/setup.typ
@@ -142,7 +142,7 @@ pane, and the index is read again once the indexer is done: `rust-analyzer
scip .`, `scip-clang`, `scip-go`, `scip-typescript index`, `scip-python
index .` or `scip-zig` (`PARDES_SCIP_RS` and the like name another, as
`PARDES_LSP_RS` does a server). Nothing indexes behind your back: run it
-again after big changes. An index of more than 32 MB is refused.
+again after big changes. An index of more than 512 MiB is refused.
= Fonts and themes <fonts-and-themes>
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;