Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#11592 closed defect (fixed)

Unit test execution is slow with real SQLite database

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: low Milestone: 1.0.2
Component: general Version: 1.0-stable
Severity: normal Keywords: unit tests sqlite
Cc: Branch:
Release Notes:

Reduced unit-test execution time when using SQLite database.

API Changes:

Description

First mentioned in comment:20:ticket:11512, here is what I get on 1.0-stable

$ make unit-testPython version: Python 2.7.4
figleaf: 
coverage: 
PYTHONPATH=.:
TRAC_TEST_DB_URI=
server-options= -p 8000 -a '*,~/tracenvs/htdigest.realm,realm' -r -e ~/tracenvs
python setup.py egg_info
running egg_info
writing requirements to Trac.egg-info/requires.txt
writing Trac.egg-info/PKG-INFO
writing top-level names to Trac.egg-info/top_level.txt
writing dependency_links to Trac.egg-info/dependency_links.txt
writing entry points to Trac.egg-info/entry_points.txt
reading manifest file 'Trac.egg-info/SOURCES.txt'
writing manifest file 'Trac.egg-info/SOURCES.txt'
python ./trac/test.py --skip-functional-tests 
...
Ran 1545 tests in 37.987s

OK
$ make db=sqlite unit-test
Python version: Python 2.7.4
figleaf: 
coverage: 
PYTHONPATH=.:
TRAC_TEST_DB_URI=sqlite:test.db
server-options= -p 8000 -a '*,~/tracenvs/htdigest.realm,realm' -r -e ~/tracenvs
python setup.py egg_info
running egg_info
writing requirements to Trac.egg-info/requires.txt
writing Trac.egg-info/PKG-INFO
writing top-level names to Trac.egg-info/top_level.txt
writing dependency_links to Trac.egg-info/dependency_links.txt
writing entry points to Trac.egg-info/entry_points.txt
reading manifest file 'Trac.egg-info/SOURCES.txt'
writing manifest file 'Trac.egg-info/SOURCES.txt'
python ./trac/test.py --skip-functional-tests 
...
Ran 1545 tests in 82.705s

OK

The results seem to be the same on 0.12-stable with and without db=sqlite.

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 5 years ago

On my system I consistently see 27 seconds for in-memory SQLite, 60 seconds with SQLite before change, < 30 seconds with SQLite after change. The execution times in comment:description are a little high since my system was doing other things at the same time.

I guess the setting is not persistent across database connections since the following change did not affect the execution time:

  • trac/test.py

    diff --git a/trac/test.py b/trac/test.py
    index 337249e..7394e64 100755
    a b class EnvironmentStub(Environment):  
    367367
    368368        if not tables:
    369369            self.global_databasemanager.init_db()
     370            if scheme == 'sqlite':
     371                # Speed-up tests with SQLite database
     372                self.db_transaction("PRAGMA synchronous = OFF")
    370373            # we need to make sure the next get_db_cnx() will re-create
    371374            # a new connection aware of the new data model - see #8518.
    372375            if self.dburi != 'sqlite::memory:':

I'll commit the changes in log:rjollos.git:t11592 to 1.0-stable if there is no additional feedback.

comment:2 by Ryan J Ollos, 5 years ago

Priority: normallow
Status: newassigned
Version: 1.0-stable

comment:3 by Jun Omae, 5 years ago

Results of timing on my system.

SQLite database Elapse
in-memory 21.978s
file on tmpfs 20.745s
file on ext4 with the changes 22.692s
file on ext4 without the changes 800.592s

comment:4 by Ryan J Ollos, 5 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in [12691], merged to trunk in [12692].

comment:5 by Ryan J Ollos, 5 years ago

Owner: changed from Ryan J Ollos to Jun Omae

comment:6 by Ryan J Ollos, 4 years ago

Changes from [12691] revised in #11967 ([13818]).

Last edited 4 years ago by Ryan J Ollos (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.