Skip to content

Commit 6d19350

Browse files
authored
Merge pull request DeusData#2358 from DeusData/fix/issue-2311
docs(pipeline): CBM_EXTRACT_BUDGET is a CPU-time parse budget, not bytes (DeusData#2311)
2 parents cb251ed + f3754d6 commit 6d19350

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎internal/cbm/cbm.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,6 @@ const char *cbm_index_quarantine_phase(const char *rel_path);
738738
void cbm_index_mark_start(const char *rel_path);
739739
void cbm_index_mark_done(const char *rel_path);
740740

741-
// Extract all data from one file. Caller must call cbm_free_result().
742-
// source must remain valid for the duration of the call.
743-
// timeout_micros: per-file parse timeout in microseconds (0 = no timeout).
744741
/* Compact a finished result: copy everything reachable from it -- every
745742
* record array at exact count, every string once (interned by content within
746743
* the file), the retained source -- into one exact-size arena, and destroy the
@@ -776,6 +773,11 @@ void cbm_work_arena_keep_begin(void);
776773
/* Free the compaction scratch this thread kept (cbm_work_arena_release calls it). */
777774
void cbm_result_compact_release_thread(void);
778775

776+
// Extract all data from one file. Caller must call cbm_free_result().
777+
// source must remain valid for the duration of the call.
778+
// timeout_micros: per-file tree-sitter parse budget in microseconds of the
779+
// calling thread's CPU time, with a wall-clock backstop of
780+
// CBM_PARSE_WALL_CEILING_FACTOR x the budget (0 = no budget).
779781
CBMFileResult *cbm_extract_file(const char *source, int source_len, CBMLanguage language,
780782
const char *project, const char *rel_path, int64_t timeout_micros,
781783
const char **extra_defines, // NULL-terminated, or NULL

‎src/pipeline/pipeline_internal.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
/* ── Shared pipeline constants ─────────────────────────────────── */
2525

26-
/* Maximum byte budget for tree-sitter extraction per file */
26+
/* Per-file tree-sitter parse budget, in MICROSECONDS of this thread's CPU time
27+
* (5 s). Passed as cbm_extract_file*()'s timeout_micros; a generous wall-clock
28+
* ceiling (CBM_PARSE_WALL_CEILING_FACTOR x, ~60 s) backstops a stuck parse.
29+
* It is a time budget, not a byte budget. */
2730
#define CBM_EXTRACT_BUDGET 5000000
2831

2932
/* Route node QN buffer size (must fit __route__METHOD__/full/url/path) */

0 commit comments

Comments
 (0)