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

lstat() dominates in the case of small coverage samples #625

Closed
nedbat opened this issue Dec 22, 2017 · 4 comments
Closed

lstat() dominates in the case of small coverage samples #625

nedbat opened this issue Dec 22, 2017 · 4 comments
Labels
enhancement New feature or request

Comments

@nedbat
Copy link
Owner

nedbat commented Dec 22, 2017

Originally reported by Buck Evan (Bitbucket: bukzor, GitHub: bukzor)


The hypothesis library recently added coverage-led fuzzing, in which it needs to run a very short test many times, while examining the coverage between each trial. This (currently) involves many calls to coverage.Collector.save_data, which in turn causes many calls to realpath (and thus lstat). In the extreme case, lstat() ends up taking about 40% of the run time.

Can you please help me design a remedy? Some alternatives that I can think of:

  1. add a cache to files.abs_file
  2. replace the call to abs_file with a call to files.canonical_path, since canonical_path already has a cache
  3. Delegate the filename-normalization responsibility from Collector to CoverageData, such that we can specialize CoverageData and fix this within our dependent library.

@nedbat
Copy link
Owner Author

nedbat commented Dec 23, 2017

Option 2 seems like the simplest thing to do, and I don't see a downside.

@nedbat
Copy link
Owner Author

nedbat commented Dec 23, 2017

Hmm, actually, canonical_filename searches for relative filenames on sys.path... I wish I understood better why it needs to do that.

@nedbat
Copy link
Owner Author

nedbat commented Dec 29, 2017

Original comment by Buck Evan (Bitbucket: bukzor, GitHub: bukzor)


I believe that's the semantics of a module with a relative __file__?

@nedbat
Copy link
Owner Author

nedbat commented May 14, 2018

This should be fixed with commit 44f0e230c68e611c9edfdf28fbdad73dd502afe5 (bb).

@nedbat nedbat closed this as completed May 14, 2018
@nedbat nedbat added major enhancement New feature or request labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant