Skip to content

Artifact discovery reads every non-Go file whole into memory #66

Done

Description

@rahlk

Describe the bug
readArtifact calls os.ReadFile on every non-.go file to hash it and to test it for UTF-8. It does this also when --artifact-text is off, on cache hits, and on -t runs. It walks node_modules, .venv and large binaries.

To Reproduce

  1. Put a 1 GB binary file in a project.
  2. Run cango -i . -a 1 and measure the peak memory.

Expected behavior
Discovery hashes each file as a stream, in constant memory. It reads the full text only when --artifact-text is set.

Logs
Measured on the old code: a 1 GB binary in the tree peaked at 1.09 GB resident. The same tree without it peaked at 27 MB.

Additional context

Activity

  1. added
    bug
    on Nov 29, 2026
  2. rahlk commented on Nov 29, 2026

    @rahlk
    ContributorAuthor

    Fixed in PR #55 (d2ae0e4): discovery hashes each file as a stream in constant memory and reads the full text only with --artifact-text. A 1 GB file now peaks at 27.8 MB, against 1.09 GB before.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions