Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of SourceMapper #6112

Conversation

dantleech
Copy link
Contributor

@dantleech dantleech commented Jan 29, 2025

Improve source map performance for directories with same path

This PR aggregates the directories to a map of paths to tuples containing prefixes and suffixes.

This will reduce the overhead of scanning paths when multiple directory elements are defined with the same path but differnet prefixes or suffixes.

For example:

<exclude>
    <directory suffix="Controller.php">src/</directory>
    <directory suffix="Factory.php">src/</directory>
    <directory suffix="Bus.php">src/</directory>
    <directory suffix="Car.php">src/</directory>
</exclude>

Would be resolved as:

[
   'src/' => [
       [], // no prefixes
       ['Controller.php', 'Factory.php', 'Bus.php', 'Car.php'],
   ],
],

The File Iterator already accepts an array of suffixes or prefixes.


Imroves perforamance in the example repository from 3.5 to 1.8 seconds.

@sebastianbergmann sebastianbergmann added feature/test-runner CLI test runner type/performance Issues related to resource consumption (time and memory) labels Jan 29, 2025
@sebastianbergmann
Copy link
Owner

This could, and probably should, target the 11.5 branch instead of main.

@sebastianbergmann
Copy link
Owner

if you approve of this approach I'll update the tests too

I would appreciate that :) This should be done in a separate PR, though, that I would merge before the change of implementation. Otherwise we would not (really/easily) know that the change of implementation does not change behaviour.

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.07%. Comparing base (5f8c741) to head (c308e73).
Report is 1 commits behind head on 11.5.

Additional details and impacted files
@@            Coverage Diff            @@
##               11.5    #6112   +/-   ##
=========================================
  Coverage     95.07%   95.07%           
- Complexity     6960     6965    +5     
=========================================
  Files           731      731           
  Lines         22244    22261   +17     
=========================================
+ Hits          21148    21165   +17     
  Misses         1096     1096           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dantleech dantleech force-pushed the gh-6111-improve-source-map-performance branch from 0c12e78 to 7a1e418 Compare January 29, 2025 21:13
@dantleech dantleech changed the base branch from main to 11.5 January 29, 2025 21:13
@dantleech dantleech force-pushed the gh-6111-improve-source-map-performance branch from 7a1e418 to 09dabf8 Compare January 29, 2025 21:27
@dantleech dantleech marked this pull request as ready for review January 29, 2025 21:27
@dantleech dantleech force-pushed the gh-6111-improve-source-map-performance branch from 09dabf8 to e70ef2f Compare January 29, 2025 21:30
This PR aggregates the directories to a map of paths to tuples
containing prefixes and suffixes.

This will reduce the overhead of scanning paths when multiple directory
elements are defined with the same path but differnet prefixes or
suffixes.

Addresses sebastianbergmann#6111
@dantleech dantleech force-pushed the gh-6111-improve-source-map-performance branch from e70ef2f to c308e73 Compare January 29, 2025 21:31
@dantleech
Copy link
Contributor Author

I've rebased, squashed and retargeted at 11.5 - I also added a few more tests as we were missing ones with multiple prefixes/suffixes on the same path.

@sebastianbergmann sebastianbergmann merged commit e9be224 into sebastianbergmann:11.5 Jan 30, 2025
31 checks passed
@sebastianbergmann sebastianbergmann changed the title Improve source map performance #6111 Improve performance of SourceMapper Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/performance Issues related to resource consumption (time and memory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants