summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;