#1338 assigned defect

reduce CLI startup overhead by importing less

Reported by: davidsarah Owned by: daira
Priority: major Milestone: soon
Component: code-frontend-cli Version: 1.8.1
Keywords: performance extensibility packaging Cc: tahoe-lafs.org@…
Launchpad Bug:

Description (last modified by lpirl)

bin/tahoe takes about 3.5 seconds to perform a trivial command (e.g. bin/tahoe --help) on my machine. Most of this overhead is due to importing dependencies: src/allmydata/__init__.py imports all of Tahoe's dependencies, in order to check their versions.

Just removing the calls to get_package_versions_and_locations() and check_all_requirements() does not work; we end up importing most of these libraries anyway. However, most of the CLI commands that do not start a node, should not need to import anything except twisted.python.usage.

By copying just the files that are needed for the CLI to work at all, and removing imports that are not really necessary, I was able to get the time to run bin/tahoe --help on my machine to 1.1 seconds, i.e. a factor-of-3 improvement. This is just a proof of concept at the moment, but I think this improvement could also be obtained for the real CLI. Note that just running a script that prints out the help text takes 0.8 seconds, due to the startup overhead of the Python interpreter.

Another major advantage of doing this is that the resulting CLI could be embedded as a library, without pulling in any of Tahoe's dependencies and their associated packaging woes.

Change History (7)

comment:1 Changed at 2011-01-27T04:24:23Z by davidsarah

I was able to get the time to run bin/tahoe --help on my machine to 1.1 seconds...

I should clarify that this was actually python bin/tahoe.py --help, with PYTHONPATH set to the bin directory, and Twisted installed globally (for twisted.python.usage). But since the refactored CLI source files could be in a single directory and don't depend on anything else, it is possible to solve the path problem more simply than we are currently doing.

comment:2 Changed at 2015-02-02T10:52:22Z by lpirl

  • Cc tahoe-lafs.org@… added
  • Description modified (diff)

comment:3 Changed at 2015-02-02T13:48:48Z by daira

  • Milestone changed from undecided to 1.12.0
  • Owner set to daira
  • Status changed from new to assigned

comment:4 Changed at 2016-03-22T05:02:25Z by warner

  • Milestone changed from 1.12.0 to 1.13.0

Milestone renamed

comment:5 Changed at 2016-06-28T18:17:14Z by warner

  • Milestone changed from 1.13.0 to 1.14.0

renaming milestone

comment:6 Changed at 2020-06-30T14:45:13Z by exarkun

  • Milestone changed from 1.14.0 to 1.15.0

Moving open issues out of closed milestones.

comment:7 Changed at 2021-03-30T18:40:19Z by meejah

  • Milestone changed from 1.15.0 to soon

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.