Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select version from coverage_schema'
EXCEPTION from execute: no such table: coverage_schema
Executing script with 1995 chars: 'CREATE TABLE coverage_schema (\n -- One row,...foreign key (file_id) references file (id)\n);\n'
Executing 'insert into coverage_schema (version) values (?)' with (7,)
Executing many 'insert or ignore into meta (key, value) values (?, ?)' with 3 rows
Executing "select value from meta where key = 'has_arcs'"
Executing 'select id, path from file'
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'insert or ignore into meta (key, value) values (?, ?)' with ('has_arcs', '1')
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing 'insert into context (context) values (?)' with ('',)
Executing 'insert or replace into file (path) values (?)' with ('a_project/__init__.py',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 2 rows
Executing 'insert or replace into file (path) values (?)' with ('a_project/foo.py',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 2 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('unittest.case._Outcome.testPartExecutor',)
Executing 'insert into context (context) values (?)' with ('unittest.case._Outcome.testPartExecutor',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('unittest.case._Outcome.testPartExecutor',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('unittest.case._Outcome.testPartExecutor',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('tests.test_foo.FooTestCase.test_foo',)
Executing 'insert into context (context) values (?)' with ('tests.test_foo.FooTestCase.test_foo',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 2 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('unittest.case._Outcome.testPartExecutor',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('unittest.case._Outcome.testPartExecutor',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('unittest.case._Outcome.testPartExecutor',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
.
----------------------------------------------------------------------
Ran 1 test in 0.007s
OK
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select id from context where context = ?' with ('',)
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Executing many 'insert or ignore into arc (file_id, context_id, fromno, tono) values (?, ?, ?, ?)' with 0 rows
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Executing 'select * from file limit 1'
Connecting to '<REDACTED>/showcase_dynamic_context_perf/.coverage'
Executing 'pragma journal_mode=off'
Executing 'pragma synchronous=off'
Describe the bug
While trying to bump the version of
coverageto 6.4.3+ on a project usingdynamic_context = test_function, I've noticed an important duration increase when running the tests throughcoverage, as the CI job went from ~15 minutes to ~30 minutes.To Reproduce
The bug was reproduced using Python 3.10.9, and the problem seems to appear in all versions of
coverageabove 6.4.3.I managed to reproduce the issue on
djangoproject, by forking the repository and creating https://github.com/mkniewallner/django/pull/2/files to adddynamic_context = test_functionand run the tests through coverage with the following 3 versions (multiple times, to avoid a possible randomness):I've also created a minimal project to more easily debug the issue: https://github.com/mkniewallner/showcase-coverage-dynamic-context-perf/.
It's important to note that I was only able to reproduce the performance regression when
dynamic_contextis set totest_function. If disabled, the performance between the 3 versions is about the same.Output of coverage debug sys
Output of pip freeze
coverage==6.4.3I've run
coverageon the project with the following command:and noticed that the output was different between 6.4.2 and 6.4.3/7.0.5.
Output for 6.4.2
Output for 6.4.3/7.0.5
We can notice a lot more SQL queries (both selects and inserts attempts with 0 rows) in 6.4.3, that we don't have on 6.4.2.
Looking through the changes between 6.4.3 and 6.4.2, I managed to track down that this is probably caused by f54428f from #1347.
To reproduce:
Running the
coveragecommand with the first commit gives the same output as the one above with 6.4.3, while running it with the second commit gives the same one as 6.4.2.Doing the same on the project where the duration increase was originally noticed also shows that the duration is back to normal with the second commit, while it takes 2x more time with the first commit.
Expected behavior
No performance regression between 6.4.2 and 6.4.3.
Additional context
I'd be happy to add additional information if what is provided is not enough.