Skip to content

Conversation

@lo1tuma
Copy link

@lo1tuma lo1tuma commented Mar 7, 2025

I’ve profiled a c8 mocha run against a huge test suite (5000+ tests) which spotted the minimatch call within shouldInstrument as a bottleneck. Since shouldInstrument is called quite often but the the exclude patterns don’t change over time a lot of CPU time is wasted parsing the same glob patterns again and again.
This change converts all glob pattern to regex patterns in the constructor, so this is only done once.
I’ve profiled the same run after applying those changes and minimatch is no longer the bottleneck, instead globSync() is the next bottleneck

@bcoe bcoe changed the title Improve performance by converting patterns to regexp only once fix(perf): Improve performance by converting patterns to regexp only once May 7, 2025
@bcoe bcoe added the ci label May 7, 2025
@bcoe
Copy link
Member

bcoe commented May 7, 2025

@lo1tuma thanks for this digging, seems smart to me to only create the regex once.

@bcoe
Copy link
Member

bcoe commented May 7, 2025

@lo1tuma it looks like this has angered the Windows gods.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants