Skip to content

fix(discover): make/cargo dep-info .d files are parsed with the D grammar #2414

Description

@Fieldnote-Echo

Version

built from source, main @ 2278498 (v0.11.0-186)

Platform

Linux (x64)

Install channel

Built from source

Binary variant

standard

What happened, and what did you expect?

.d always maps to D (src/discover/language.c:406). Make-style dependency files written by cargo/rustc, gcc/clang -MD and CMake therefore go through the D grammar and then the unbudgeted unified walk (internal/cbm/cbm.c:301). They yield nothing useful, and the cost grows superlinearly with size: a 128 KB cargo dep-info file takes about 2 s to parse and 13 s to walk. Discovery always skips only target/, so a cargo --target-dir with another name, or in-tree -MD output that is not gitignored, gets indexed.

My fix adds cbm_disambiguate_d, a 4 KB first-line sniff in the shape of the .frm/.cls/.m disambiguators (#2074) and the new .res one (#2352). It drops a .d file only when its first non-blank line is a make rule whose targets all look like paths, and keeps D on any doubt. Dep-info files lose their File/Module/Folder nodes (they were never D source), so please confirm that is the behavior you want.

Reproduction

Repro: copy the .d files from a cargo target/debug/deps into a directory with a few .rs files and index it.

Linux x86_64, 32 logical CPUs, GCC 16 main fixed
Cold index, 200 real cargo dep-info files (16-205 KB) + 3 .rs 109 s, 858 CPU-s, 327 MB RSS, 17 parse timeouts 1.3 s, 1.0 CPU-s, 81 MB, 0 timeouts
Real cargo dep-info files detected as D 26,157 of 26,157 0
Real D files detected as D (phobos, dmd, ldc, dub, vibe.d) 12,062 of 12,062 12,062 of 12,062

Logs


Diagnostics trajectory (memory / performance / leak issues)

Not a leak: the CPU time and peak RSS above are for one cold index run of the repro directory.

Project scale (if relevant)

No response

Confirmations

  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Activity

  1. added
    parsing/qualityGraph extraction bugs, false positives, missing edges
    priority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.
    on Oct 1, 2026
  2. DeusData commented on Oct 1, 2026

    @DeusData
    Owner

    Thank you for the measurements and for explicitly asking about the graph-content change. Yes: in principle, confidently recognized Make/Cargo dependency artifacts should be excluded rather than indexed as D source, including omitting their file/module nodes and any folders left with no indexed content. Ambiguous .d files must remain eligible as D source. The current extension table maps .d to D, so this needs a conservative disambiguation rule, not a blanket extension exclusion. This approves that direction, subject to review of the implementation, negative controls and preservation of real D inputs. It is not a merge approval. Thank you for keeping the behavior decision explicit.

  3. Fieldnote-Echo commented on Oct 1, 2026

    @Fieldnote-Echo
    Author

    Thanks. I pushed the graph-level test and two disambiguation fixes to #2421 (head 006f2a9).

    pipeline_d_dep_info_leaves_no_nodes indexes a cargo dep-info file alone under its own directory and a gcc -MD file next to real D source. The dep-info files get no File or Module node, the dependency-only directory chain gets no Folder node, and the D file keeps its File, Module and shared Folder. With the probe disabled it fails with three Folder nodes.

    lang_d_source_stays_dlang now also covers float attributes (@1.0:), comments between tokens (public/**/:) and every D whitespace between tokens, including form feed, vertical tab, U+2028 and U+2029. The probe still reads at most 4 KB, a user .d override still skips it, and anything uncertain stays D. On real inputs, 12,062 of 12,062 D files from phobos, dmd, ldc, dub and vibe.d still detect as D. One trade-off: a dep-info file whose target path contains @ stays D, as on main.

    CI is pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingparsing/qualityGraph extraction bugs, false positives, missing edgespriority/highNeeds near-term maintainer attention; high-impact bug, regression, safety issue, or release blocker.stability/performanceServer crashes, OOM, hangs, high CPU/memory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions