Skip to content

[BUG] Paying performance costs of calling HostedGit.fromUrl with non-URLs #219

@Thristhart

Description

@Thristhart

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When profiling npm ci, I observed that 20% of the CPU time spent in my monorepo was URL.parse, and almost all of that time is in HostedGit.fromUrl. Which is a cost that feels bad to pay in my monorepo, which has a single git URL as a specifier out of thousands of dependencies otherwise.

Expected Behavior

HostedGit.fromUrl would only be invoked if the specifier being resolved looks like a URL.

Steps To Reproduce

  • Attach a profiler to an npm ci invocation, e.g. by running node --inspect-brk <path to npm.js> ci.
  • Record a performance profile while npm ci is run
  • URL.parse has the most self time

Environment

  • npm: 11.6.0
  • Node: 22.17.0
  • OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds an initial review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions