Skip to content

Commit 46c7902

Browse files
authored
refactor(native): extract constants and shared barrel resolution (#842)
* refactor(native): extract magic numbers to named constants Extract hardcoded magic numbers to named constants in constants.rs: - Louvain: MAX_LEVELS=50, MAX_PASSES=20, MIN_GAIN=1e-12, DEFAULT_SEED=42 - Dataflow: TRUNCATION_LIMIT=120 - Build pipeline: FAST_PATH_MAX_CHANGED_FILES=5, FAST_PATH_MIN_EXISTING_FILES=20 Also extract DEFAULT_RANDOM_SEED=42 in TS louvain.ts. * refactor(native): extract shared barrel resolution into common module * fix(native): correct type mismatch and elide redundant lifetime Change FAST_PATH_MIN_EXISTING_FILES from usize to i64 to match the return type of structure::get_existing_file_count, fixing the Rust compile error. Also elide the unnecessary named lifetime on resolve_barrel_export since the return type is fully owned. * docs: add explanatory note for 3.9.0 fnDeps regression and missing versions Address Greptile review feedback: - Add Note (3.9.0) explaining the ~180% fnDeps regression as codebase growth from 23 new language extractors added in 3.7.0-3.8.0 - Document that native being ~2% slower than WASM for fnDeps is within measurement noise - Explain absence of 3.8.0/3.8.1 query benchmark rows (data removed due to pre-fix measurement)
1 parent 6a0077f commit 46c7902

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/codegraph-core/src/barrel_resolution.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ pub trait BarrelContext {
3131
/// Mirrors `resolveBarrelExport()` in `resolve-imports.ts`.
3232
/// The caller provides a `visited` set to prevent infinite loops on circular
3333
/// reexport chains.
34-
pub fn resolve_barrel_export<'a, C: BarrelContext>(
35-
ctx: &'a C,
34+
pub fn resolve_barrel_export<C: BarrelContext>(
35+
ctx: &C,
3636
barrel_path: &str,
3737
symbol_name: &str,
3838
visited: &mut HashSet<String>,

generated/benchmarks/QUERY-BENCHMARKS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ Latencies are median over 5 runs. Hub target = most-connected node.
7979

8080
<!-- NOTES_START -->
8181

82+
**Note (3.9.0):** The ↑177-184% fnDeps regression (9.7ms → 27ms) reflects substantial codebase growth between 3.7.0 and 3.9.0 — many new language extractors were added across 3.7.0-3.8.0 (Elixir, Lua, Dart, Zig, Haskell, OCaml, F#, Gleam, Clojure, Julia, R, Erlang, C, C++, Kotlin, Swift, Scala, Bash, Solidity, Objective-C, CUDA, Groovy, Verilog), significantly increasing the `buildGraph` hub node's edge count. The `findCallersBatch` path was also refactored in 3.8.1 (PR #815). fnImpact and diffImpact grew only 8-14%, consistent with normal expansion. The native engine being marginally slower than WASM for fnDeps (27.4ms vs 26.9ms, ~2%) is within measurement noise and not a meaningful inversion. Versions 3.8.0 and 3.8.1 are absent because their query benchmark data was removed — v3.8.1 was measured before the `findCallersBatch` fix and showed artificially inflated fnDeps latencies; v3.8.0 had no separate query benchmark run.
83+
8284
**Note (3.6.0):** Native deltas are relative to 3.4.1 (the last version with native data; 3.5.0 was wasm-only). The mid-query target changed from `db` (3.5.0) to `node`, which affects diffImpact scope and explains the ↑41% WASM diffImpact jump (6.4ms → 9ms). fnDeps/fnImpact growth of 6-10% is consistent with codebase expansion across two releases.
8385

8486
**Note (3.5.0):** This version has WASM-only data (`native: null`) because the native engine crashed during `insertNodes` in the graph build phase. The root cause is a napi-rs serialization bug: parameter and child nodes with undefined `visibility` fields marshal as `null` at the JS-Rust boundary, which fails conversion into the Rust `Option<String>` type in `InsertNodesDefinition.visibility`. The mid-query target also changed from `noTests` to `db`, which may affect diffImpact scope. Query latencies for 3.5.0 are therefore not directly comparable to prior versions that include both engine rows. This will be fixed in the next release.

0 commit comments

Comments
 (0)