Commit Graph

320 Commits

Author SHA1 Message Date
David Wilson 84e9d42e71 ansible: handle local connections and synchronize module too. 2018-03-19 21:58:29 +05:45
David Wilson fa804c7c80 parent: simplify route() call
Doesn't need to go via defer() since it's always running on the broker
thread.
2018-03-19 21:58:29 +05:45
David Wilson 08b80b543f Some gitignore extras 2018-03-19 21:58:29 +05:45
David Wilson bdd8648bae ssh: enable compression by default
Using the same test as in 7af97c0365,
transmitted wire bytes drops from 135,531 to 133,071 (-1.81%), while
received drops from 21,073 to 14,775 (-30%).

Combined, both changes shave 13,914 bytes (-8.6%) off aggregate
bandwidth usage.

Make it configurable as compression hurts in some scenarios.
2018-03-19 21:58:29 +05:45
David Wilson ccd9c62399 tests: stubs for future whitelist/blacklist tests. 2018-03-19 21:58:29 +05:45
David Wilson 74468abf0a ansible: fix syntax error 2018-03-19 21:58:29 +05:45
David Wilson 1fb848b5e6 examples: add test case for local Ansible connections 2018-03-19 21:58:29 +05:45
David Wilson 2a786ce146 docs: fix preamble_size.py after whitelist changes 2018-03-19 21:58:29 +05:45
David Wilson 4d940f08ae importer: drop redundant prefix from pkg_present
For the 52 submodules of ansible.modules.system, this produced a 1602
byte pkg_present list. After stripping it becomes 406 bytes, and the
entire LOAD_MODULE size drops from 1988 bytes to 792 bytes (-60%).

For the 68 submodules of ansible.module_utils, 1902 bytes pkg_present
becomes 474 bytes (-75%), and LOAD_MODULE size drops from 2867 bytes to
1439 bytes (-49%).

In a simple test running Ansible's "setup" module followed by its "apt"
module, wire bytes sent drops from 140,357 to 135,531 (-3.4%).
2018-03-19 21:58:29 +05:45
David Wilson 6e7bb4fd13 ansible: support local connections too 2018-03-19 21:58:29 +05:45
David Wilson 71a6b9e32a master: Select.all() sugar 2018-03-19 21:58:29 +05:45
David Wilson 4aacf2da4c ansible: we're gonna need more playbook steps 2018-03-19 21:58:29 +05:45
David Wilson 57894b18e0 ansible: support class_only=True in wrapped loader 2018-03-19 21:58:29 +05:45
David Wilson 54a3777ff3 ansible: blacklist everything except our own namespaces
Farewell, pointless roundtrips, we hardly knew ye.
2018-03-19 21:58:29 +05:45
David Wilson b543b84e80 importer: share blacklist logic between master/parent 2018-03-19 21:58:29 +05:45
David Wilson 8ec6ae1da0 importer: module whitelist/blacklist support
Hoped to avoid it, but it's the obvious solution for Ansible.
2018-03-19 21:58:29 +05:45
David Wilson 43ba1c76dc core: wrap selects in EINTR handlers
This isn't nearly enough, but it catches the most common victim of
EINTR.
2018-03-19 21:58:29 +05:45
David Wilson aafe458a13 core: #39: don't call logging framework when logging is disabled
It looks ugly as sin, but this nets about a 20% drop in user CPU time,
and close to 15% increase in throughput.

The average log call is around 10 opcodes, prefixing with '_v and' costs
an extra 2, but both are simple operations, and the remaining 10 are
skipped entirely when _v or _vv are False.
2018-03-19 21:58:29 +05:45
David Wilson 331f77ee2b ansible: generalized action module wrapping. 2018-03-19 21:58:29 +05:45
David Wilson 2a097dfaf8 examples: import client/server.py test scripts as examples 2018-03-19 21:58:29 +05:45
David Wilson ac4a42a43e docs: fix Select() example for new style API. 2018-03-19 21:58:29 +05:45
David Wilson e59cc89059 examples: fix mitop example. 2018-03-19 21:58:29 +05:45
David Wilson 2ce71b338b unix: add small explainer note until real docs exist 2018-03-19 21:58:29 +05:45
Alex Willmer a69d9650ad Fix indentation of Router.route anchor 2018-03-19 21:58:29 +05:45
Alex Willmer f4405c6bbc Split IterReadTest & WriteAllTest into test_parent
This matches their respective functions under test, which now reside in
mitogen.parent.
2018-03-19 21:58:29 +05:45
Alex Willmer 4fb1b928b7 Adjust unittest for master -> parent split
Tests should now match changes in
4d31300dd0
2018-03-19 21:58:29 +05:45
Alex Willmer 9ccff0f5d1 Fix TypeError while initiliazing ImporterMixin
Since f44356af32 mitogen.core.Importer()
takes a Router instance.
2018-03-19 21:58:29 +05:45
Alex Willmer eb1ad66469 docs: Fix out of date get_data() snippets
As of adc8fe3aed Receiver objects do not
have a get_data() method and Receiver.get() does not unpickle the
message.
2018-03-19 21:58:29 +05:45
Alex Willmer 3261c561dd Fix AttributeError in mitogen.core.Context.send_await()
As of adc8fe3aed Receiver objects do not
have a get_data() method and Receiver.get() does not unpickle the
message.
2018-03-19 21:58:29 +05:45
Alex Willmer fa0f390d4d FIx syntax error in FindRelatedImportsTest.test_django_db_models 2018-03-19 21:58:29 +05:45
David Wilson 6905dc4e8d master: use queue-like Latch in Select() too. 2018-03-19 21:58:29 +05:45
David Wilson d13ab9a022 ansible: remove hard-wired UNIX socket path. 2018-03-19 21:58:29 +05:45
David Wilson 20afa5b90c Latch v2: combined queue + one self-pipe-per-thread
Turns out it is far too easy to burn through available file descriptors,
so try something else: self-pipes are per thread, and only temporarily
associated with a Lack that wishes to sleep.

Reduce pointless locking by giving Latch its own queue, and removing
Queue.Queue() use in some places.

Temporarily undo merging of of Waker and Latch, let's do this one step
at a time.
2018-03-19 21:58:29 +05:45
David Wilson e6a107c5aa core: replace Queue with Latch
On Python 2.x, operations on pthread objects with a timeout set actually
cause internal polling. When polling fails to yield a positive result,
it quickly backs off to a 50ms loop, which results in a huge amount of
latency throughout.

Instead, give up using Queue.Queue.get(timeout=...) and replace it with
the UNIX self-pipe trick. Knocks another 45% off my.yml in the Ansible
examples directory against a local VM.

This has the potential to burn a *lot* of file descriptors, but hell,
it's not the 1940s any more, RAM is all but infinite. I can live with
that.

This gets things down to around 75ms per playbook step, still hunting
for additional sources of latency.
2018-03-19 21:58:29 +05:45
David Wilson 27f1eddbd4 ansible: delete old needless host_vars directory 2018-03-19 21:58:29 +05:45
David Wilson beb16d0db6 master: helper functions to force disconnect everything 2018-03-19 21:58:29 +05:45
David Wilson 9b5d0a9b97 service: initial version 2018-03-19 21:58:29 +05:45
David Wilson 6059e0c1db ansible: support become:True and become_user 2018-03-19 21:58:29 +05:45
David Wilson 8204dc69e7 ansible: add become test case 2018-03-19 21:58:29 +05:45
David Wilson ed09076bdd ansible: automatically configure connection plug-in. 2018-03-19 21:58:29 +05:45
David Wilson a35fcf44cc ansible: restructure to avoid intermediate imports 2018-03-19 21:58:29 +05:45
David Wilson 3fc673563d ansible: import example playbook 2018-03-19 21:58:29 +05:45
David Wilson 75a78c9ff4 ansible: connection plugin v2
Now featuring one roundtrip per module invocation.
2018-03-19 21:58:29 +05:45
David Wilson f3e51a7b18 core: CALL_FUNCTION should check auth_id, not src_id 2018-03-19 21:58:29 +05:45
David Wilson f001eba23e ansible: Merge module runner into helpers.py. 2018-03-19 21:58:28 +05:45
David Wilson 67d4c13ffa Remove old TCP draft. 2018-03-19 21:58:28 +05:45
David Wilson 32f6ee7d43 issue #40: mitogen.unix initial implementation. 2018-03-19 21:58:28 +05:45
David Wilson 37e3151be8 fakessh: restore unpickle() semantics. 2018-03-19 21:58:28 +05:45
David Wilson e63e9d299e docs: add Message documentation 2018-03-19 21:58:28 +05:45
David Wilson 10230f62dd core: Message.reply() helper function 2018-03-19 21:58:28 +05:45