Skip to content

Optimise Scenario  #1434

@PietroPasotti

Description

@PietroPasotti

The unit testing suite for traefik is probably the largest scenario test battery around.
Today I ran it and I realized it took over a minute and a half to complete, so I decided to profile it.

This is the result:
image

to produce the profile, run with this tox env:

[testenv:profile-scenario-tests]
description = Profile scenario unit test battery
deps =
    pytest
    pytest-profiling
    ops[testing]>=2.17
    -r{toxinidir}/requirements.txt
commands =
    pytest -v --tb native {[vars]tst_path}/scenario --profile --profile-svg --log-cli-level=INFO -s {posargs}

There are some obvious candidates for optimization:

  • using an in-memory mock for the sqlite db instead of using the real thing could shave off a good chunk of time spent in pointless IO
  • A ridiculous amount of time is spent in State.__new__. Can we do something about that?
  • how come mocking juju-log takes so long?
  • A single list comprehension in state.py:143 takes 2 seconds of our time: can we lazify some of the code perhaps?

profiling scenario's own test suite yields a very similar picture:
image

Metadata

Metadata

Labels

testsRelated to tests or testing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions