gitnexus 1.6.10-rc.47 → 1.6.10-rc.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -471,6 +471,8 @@ Configure the behavior with these environment variables:
|
|
|
471
471
|
| `GITNEXUS_FTS_CJK_SEGMENTATION` | `none`, `bigram` | `none` | `bigram` inserts overlapping character-bigram boundaries into Chinese/Japanese Han-ideograph spans in `content`/`description` before FTS indexing, so LadybugDB's space-only tokenizer can see sub-phrase word boundaries. Scoped to CJK Unified Ideographs only — Japanese Hiragana/Katakana and Korean Hangul are not currently segmented. Unlike `GITNEXUS_FTS_STEMMER`, this rewrites stored text — enabling it on an already-indexed repo requires a full `gitnexus analyze --force`; neither `--repair-fts` nor a plain incremental `analyze` applies it to previously-indexed files. Set the same value wherever `analyze` and search-serving processes (CLI query, MCP server, web server) run. |
|
|
472
472
|
| `GITNEXUS_COMMUNITY_ENGINE` | `graphology`, `icebug`, `auto` | `graphology` | Community-detection engine used during analyze. `graphology` uses the bundled default path. `icebug` and `auto` currently behave identically: both try the experimental Icebug CSR path and fall back to Graphology if the optional native module is unavailable or incompatible. |
|
|
473
473
|
| `GITNEXUS_WAL_CHECKPOINT_THRESHOLD` | integer `>= -1` | `67108864` (64 MiB) | LadybugDB WAL auto-checkpoint threshold during analyze (bytes). Auto-checkpoint remains enabled; `-1` keeps Ladybug's stock ~16 MiB. Larger thresholds reduce checkpoint frequency but increase the WAL size at rotation time — choose a smaller value on disk-constrained environments. |
|
|
474
|
+
| `GITNEXUS_LBUG_BUFFER_POOL_SIZE` | integer `>= 0` (bytes) | min(2 GiB, 80% RAM) | LadybugDB buffer-pool ceiling for every GitNexus database (analyze, MCP server, serve, group bridges). Bounded so a long-lived `gitnexus mcp` process or a large incremental `analyze` cannot grow toward LadybugDB's native 80%-of-RAM default and OOM the host (#2557). `0` restores that native unbounded default; invalid values warn and fall back to the default. |
|
|
475
|
+
| `GITNEXUS_LBUG_MAX_DB_SIZE` | positive integer (bytes) | `17179869184` (16 GiB) | Upper bound for a single LadybugDB database file. This is an mmap/disk-address-space ceiling, not a memory limit — it does not constrain the buffer pool (use `GITNEXUS_LBUG_BUFFER_POOL_SIZE` for that). Raise it when indexing genuinely huge monorepos; invalid values silently fall back to the default. |
|
|
474
476
|
|
|
475
477
|
```bash
|
|
476
478
|
# Offline/airgapped: never reach the network for extensions
|
|
@@ -39,8 +39,15 @@ export declare function resolveNativeSafeStorageDir(storagePath: string, subdir:
|
|
|
39
39
|
* `true` (0.16.0). Existing call sites that relied on the positional
|
|
40
40
|
* default must now pass `false` explicitly to preserve behaviour.
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* 3. `bufferManagerSize` (not a 0.16.0 change, same pin-explicitly
|
|
43
|
+
* principle): `0` means "native default", and the native default buffer
|
|
44
|
+
* pool is 80% of physical RAM. A long-lived `gitnexus mcp` process or a
|
|
45
|
+
* large incremental analyze can balloon to that ceiling and OOM-kill the
|
|
46
|
+
* host session (#2557), so GitNexus pins an explicit bounded pool — see
|
|
47
|
+
* `resolveBufferManagerSize`.
|
|
48
|
+
*
|
|
49
|
+
* Putting these in one shared module guarantees every `new lbug.Database(...)`
|
|
50
|
+
* call site agrees on the same ceilings and behaviour.
|
|
44
51
|
*/
|
|
45
52
|
/**
|
|
46
53
|
* Upper bound for any single GitNexus LadybugDB file (graph index, group
|
|
@@ -227,8 +227,15 @@ export function resolveNativeSafeStorageDir(storagePath, subdir) {
|
|
|
227
227
|
* `true` (0.16.0). Existing call sites that relied on the positional
|
|
228
228
|
* default must now pass `false` explicitly to preserve behaviour.
|
|
229
229
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
230
|
+
* 3. `bufferManagerSize` (not a 0.16.0 change, same pin-explicitly
|
|
231
|
+
* principle): `0` means "native default", and the native default buffer
|
|
232
|
+
* pool is 80% of physical RAM. A long-lived `gitnexus mcp` process or a
|
|
233
|
+
* large incremental analyze can balloon to that ceiling and OOM-kill the
|
|
234
|
+
* host session (#2557), so GitNexus pins an explicit bounded pool — see
|
|
235
|
+
* `resolveBufferManagerSize`.
|
|
236
|
+
*
|
|
237
|
+
* Putting these in one shared module guarantees every `new lbug.Database(...)`
|
|
238
|
+
* call site agrees on the same ceilings and behaviour.
|
|
232
239
|
*/
|
|
233
240
|
/**
|
|
234
241
|
* Upper bound for any single GitNexus LadybugDB file (graph index, group
|
|
@@ -286,6 +293,53 @@ const resolveCheckpointThreshold = () => {
|
|
|
286
293
|
}
|
|
287
294
|
return DEFAULT_WAL_CHECKPOINT_THRESHOLD;
|
|
288
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* Default ceiling for the LadybugDB buffer pool in bytes (#2557).
|
|
298
|
+
*
|
|
299
|
+
* The pool is a page cache with eviction, so the ceiling trades throughput
|
|
300
|
+
* on very large working sets for a machine that stays alive: 2 GiB is
|
|
301
|
+
* ~40× the GitNexus self-index, while the native 80%-of-RAM default let a
|
|
302
|
+
* `detect_changes` call grow a 105 MiB on-disk index to 19.5 GiB RSS and
|
|
303
|
+
* OOM-kill the reporter's session. The `min` with 80% of `os.totalmem()`
|
|
304
|
+
* keeps sub-2.5-GiB machines at the native-equivalent bound (no regression
|
|
305
|
+
* there); the 64 MiB floor keeps tiny containers above any plausible
|
|
306
|
+
* native minimum pool size.
|
|
307
|
+
*/
|
|
308
|
+
const DEFAULT_BUFFER_POOL_CAP = 2 * 1024 * 1024 * 1024;
|
|
309
|
+
const BUFFER_POOL_FLOOR = 64 * 1024 * 1024;
|
|
310
|
+
const parseBufferPoolSize = (raw) => {
|
|
311
|
+
if (raw === undefined)
|
|
312
|
+
return undefined;
|
|
313
|
+
const normalized = raw.trim();
|
|
314
|
+
if (normalized.length === 0)
|
|
315
|
+
return undefined;
|
|
316
|
+
const parsed = Number(normalized);
|
|
317
|
+
if (!Number.isFinite(parsed) || parsed < 0)
|
|
318
|
+
return undefined;
|
|
319
|
+
return Math.floor(parsed);
|
|
320
|
+
};
|
|
321
|
+
const defaultBufferPoolSize = () => Math.min(DEFAULT_BUFFER_POOL_CAP, Math.max(BUFFER_POOL_FLOOR, Math.floor(os.totalmem() * 0.8)));
|
|
322
|
+
/**
|
|
323
|
+
* Resolve the `bufferManagerSize` passed to every `new lbug.Database(...)`.
|
|
324
|
+
* `GITNEXUS_LBUG_BUFFER_POOL_SIZE` (bytes) overrides the default; `0` is a
|
|
325
|
+
* deliberate escape hatch that restores LadybugDB's native unbounded
|
|
326
|
+
* 80%-of-RAM default. Resolved at call time (not module load) so tests can
|
|
327
|
+
* stub the env var and `os.totalmem`.
|
|
328
|
+
*/
|
|
329
|
+
const resolveBufferManagerSize = () => {
|
|
330
|
+
const raw = process.env.GITNEXUS_LBUG_BUFFER_POOL_SIZE;
|
|
331
|
+
if (raw === undefined)
|
|
332
|
+
return defaultBufferPoolSize();
|
|
333
|
+
const parsed = parseBufferPoolSize(raw);
|
|
334
|
+
if (parsed !== undefined)
|
|
335
|
+
return parsed;
|
|
336
|
+
// Non-empty but unparseable input: warn the operator and fall back —
|
|
337
|
+
// mirrors the GITNEXUS_WAL_CHECKPOINT_THRESHOLD env path above.
|
|
338
|
+
if (raw.trim().length > 0) {
|
|
339
|
+
logger.warn({ rawValue: raw, fallback: defaultBufferPoolSize() }, `Ignoring invalid GITNEXUS_LBUG_BUFFER_POOL_SIZE=${raw}; expected integer >= 0 (bytes; 0 restores the native 80%-of-RAM default); falling back to min(2 GiB, 80% of RAM).`);
|
|
340
|
+
}
|
|
341
|
+
return defaultBufferPoolSize();
|
|
342
|
+
};
|
|
289
343
|
/** Matches WAL corruption errors from the LadybugDB engine. */
|
|
290
344
|
const WAL_CORRUPTION_RE = /corrupt(ed)?\s+wal|invalid\s+wal\s+record|wal.*corrupt|checksum.*wal/i;
|
|
291
345
|
export const WAL_RECOVERY_SUGGESTION = 'WAL corruption detected. Run `gitnexus analyze --force` to rebuild the index.';
|
|
@@ -496,7 +550,7 @@ export const classifyDeleteAllError = (err) => {
|
|
|
496
550
|
};
|
|
497
551
|
export function createLbugDatabase(lbugModule, databasePath, options = {}) {
|
|
498
552
|
// .d.ts declares fewer args than the native constructor accepts.
|
|
499
|
-
return new lbugModule.Database(databasePath,
|
|
553
|
+
return new lbugModule.Database(databasePath, resolveBufferManagerSize(), // bufferManagerSize (#2557: default min(2 GiB, 80% RAM); GITNEXUS_LBUG_BUFFER_POOL_SIZE overrides; 0 restores the native 80%-of-RAM default)
|
|
500
554
|
false, // enableCompression (pinned for v0.16.0)
|
|
501
555
|
options.readOnly ?? false, LBUG_MAX_DB_SIZE, true, // autoCheckpoint (always on)
|
|
502
556
|
resolveCheckpointThreshold(), // checkpointThreshold (default 64 MiB; override with GITNEXUS_WAL_CHECKPOINT_THRESHOLD; -1 keeps Ladybug stock ~16 MiB)
|
package/package.json
CHANGED