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

CoverageMappingReader behaves O(N^2) slowly with hundreds thousand of Expansions #113173

Open
chapuni opened this issue Oct 21, 2024 · 0 comments · May be fixed by #122589
Open

CoverageMappingReader behaves O(N^2) slowly with hundreds thousand of Expansions #113173

chapuni opened this issue Oct 21, 2024 · 0 comments · May be fixed by #122589

Comments

@chapuni
Copy link
Contributor

chapuni commented Oct 21, 2024

For example RISCVInstructionSelector.cpp (possibly since #110782):

  • NumRegions 892,077
  • NumFiles 387,470 (Expansions)

It takes bunch of minutes for me.

llvm-cov is not required for reproduction. Just add -Xclang -dump-coverage-mapping onto -profile-instr-generate -fcoverage-mapping. The dump calls CoverageMappingReader for encoded covmap.

chapuni added a commit that referenced this issue Jan 11, 2025
This improves `-dump-coverage-mapping` (939,498 lines) for
`RISCVInstructionSelector.cpp` from 30m to 1m18s and also improves
`llvm-cov` for `check-llvm` from 33m to 24s.

The current implementation behaved O(N^2) order with hundreds
thousands of Expansions.

This assumes:
  - Records are partitioned by FileID.
    - ExpandedFileID doesn't point FileID==0, since it is the root.
  - The Count in Expansion is propagated from 1st Record in
    ExpandedFileID.

Therefore another fact below can be assumed.
  - Propagation chain consists of Expansions at each 1st Record.

This scans the Record at most a few times. O(N) is expected.

Fixes #113173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants