From ff3717ac580e1fe1f4606c19c860ea9c202968fe Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 7 Jan 2023 15:01:13 -0500 Subject: [PATCH] perf: the file mapping cache was off by mistake. #1527 --- CHANGES.rst | 7 ++++++- CONTRIBUTORS.txt | 1 + coverage/collector.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 19d4135fe..b7a7a2354 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,7 +20,12 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- -Nothing yet. +- Performance: an internal cache of file names was accidentally disabled, + resulting in sometimes drastic reductions in performance. This is now fixed, + closing `issue 1527`_. Thanks to Ivan Ciuvalschii for the reproducible test + case. + +.. _issue 1527: https://github.com/nedbat/coveragepy/issues/1527 .. _changes_7-0-3: diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index af6c4c26a..012963d16 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -81,6 +81,7 @@ Hugo van Kemenade Ilia Meerovich Imri Goldberg Ionel Cristian Mărieș +Ivan Ciuvalschii J. M. F. Tsang JT Olds Jerin Peter George diff --git a/coverage/collector.py b/coverage/collector.py index a3c537d66..90a5ba057 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -433,7 +433,7 @@ def disable_plugin(self, disposition: TFileDisposition) -> None: plugin._coverage_enabled = False disposition.trace = False - @functools.lru_cache(maxsize=0) + @functools.lru_cache(maxsize=None) def cached_mapped_file(self, filename: str) -> str: """A locally cached version of file names mapped through file_mapper.""" return self.file_mapper(filename)