Commit Graph

581 Commits

Author SHA1 Message Date
David Wilson 5529a4fba6 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-02-15 15:38:52 +05:45
David Wilson d0fbcc0f48 ansible: generalized action module wrapping. 2018-02-15 15:30:19 +05:45
David Wilson e5146df214 examples: import client/server.py test scripts as examples 2018-02-15 06:17:07 +05:45
David Wilson af04f24c95 docs: fix Select() example for new style API. 2018-02-15 06:03:01 +05:45
David Wilson 762dbcef3d examples: fix mitop example. 2018-02-15 00:05:41 +00:00
David Wilson fce44a5843 unix: add small explainer note until real docs exist 2018-02-15 05:31:50 +05:45
dw 3e20b5036f
Merge pull request #79 from moreati/doc-router-route
Fix indentation of Router.route anchor
2018-02-15 05:26:41 +05:45
dw feacb2bd40
Merge pull request #80 from moreati/sins-of-the-parent
Fix/split test_master tests following split of mitogen.master -> mitogen.parent
2018-02-15 05:26:24 +05:45
dw d708405126
Merge pull request #82 from moreati/imported-via-the-scenic-route
Fix TypeError while initiliazing ImporterMixin
2018-02-15 05:26:05 +05:45
dw 9d1859796c
Merge pull request #83 from moreati/msg-in-a-jar
Fix lingering references to mitogen.core.Receiver.get_data()
2018-02-15 05:24:58 +05:45
dw fdb379ba0b
Merge pull request #81 from moreati/django-unfound
FIx syntax error in FindRelatedImportsTest.test_django_db_models
2018-02-15 05:24:49 +05:45
David Wilson 0d57afc914 master: use queue-like Latch in Select() too. 2018-02-15 05:23:48 +05:45
Alex Willmer 3bf204f8d6 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-02-14 23:30:25 +00:00
Alex Willmer c1e29783fb 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-02-14 23:27:54 +00:00
David Wilson 371a259a5e ansible: remove hard-wired UNIX socket path. 2018-02-15 04:55:56 +05:45
David Wilson a6324aaeb1 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-02-15 04:52:29 +05:45
Alex Willmer 83c0111b51 Fix TypeError while initiliazing ImporterMixin
Since f44356af32 mitogen.core.Importer()
takes a Router instance.
2018-02-14 23:04:10 +00:00
Alex Willmer 49b6c586e3 FIx syntax error in FindRelatedImportsTest.test_django_db_models 2018-02-14 22:54:00 +00:00
Alex Willmer 5ba2db0794 Split IterReadTest & WriteAllTest into test_parent
This matches their respective functions under test, which now reside in
mitogen.parent.
2018-02-14 22:48:31 +00:00
Alex Willmer f114c5951b Adjust unittest for master -> parent split
Tests should now match changes in
4d31300dd0
2018-02-14 22:40:09 +00:00
Alex Willmer 631c97b143 Fix indentation of Router.route anchor 2018-02-14 21:12:29 +00:00
David Wilson 8121530144 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-02-15 02:06:21 +05:45
David Wilson 1c6e529458 ansible: delete old needless host_vars directory 2018-02-15 01:03:28 +05:45
David Wilson bb662a1a0b master: helper functions to force disconnect everything 2018-02-15 00:45:09 +05:45
David Wilson 4a431a1a85 service: initial version 2018-02-15 00:44:31 +05:45
David Wilson d3e79fc240 ansible: support become:True and become_user 2018-02-15 00:27:23 +05:45
David Wilson 2efb790a2f ansible: add become test case 2018-02-15 00:27:05 +05:45
David Wilson 3a96389d08 ansible: automatically configure connection plug-in. 2018-02-15 00:14:38 +05:45
David Wilson 8598ff07b3 ansible: restructure to avoid intermediate imports 2018-02-14 22:30:35 +05:45
David Wilson 1a119cb08b ansible: import example playbook 2018-02-14 22:29:02 +05:45
David Wilson 715e42a714 ansible: connection plugin v2
Now featuring one roundtrip per module invocation.
2018-02-14 22:17:42 +05:45
David Wilson 7819819188 core: CALL_FUNCTION should check auth_id, not src_id 2018-02-14 22:00:51 +05:45
David Wilson 5a04fbb694 ansible: Merge module runner into helpers.py. 2018-02-14 21:27:14 +05:45
David Wilson 1d5de9017f Remove old TCP draft. 2018-02-14 21:02:54 +05:45
David Wilson 3dd062bc18 issue #40: mitogen.unix initial implementation. 2018-02-14 21:02:43 +05:45
David Wilson aa1d58c9a3 fakessh: restore unpickle() semantics. 2018-02-14 20:25:53 +05:45
David Wilson dadee5dc05 docs: add Message documentation 2018-02-14 20:24:39 +05:45
David Wilson 424879dfb4 core: Message.reply() helper function 2018-02-14 20:13:30 +05:45
David Wilson 0a4711bce9 core: Don't crash if a stream is missing a side. 2018-02-14 19:46:30 +05:45
David Wilson 43c673b230 core: Restore behaviour of unpickling Router-specific Context subclass 2018-02-14 19:45:46 +05:45
David Wilson 8ef87bea6a select: clean up API. 2018-02-14 19:45:22 +05:45
David Wilson adc8fe3aed core: de-munge Message.unpickle() vs. Receiver.get(). 2018-02-14 19:36:00 +05:45
David Wilson c9affbaf50 core: add auth_id field. 2018-02-14 09:16:27 +05:45
David Wilson 01c607cc67 core: remove unused SecurityError. 2018-02-14 06:42:12 +05:45
David Wilson ddf4a21bac Add mitogen.main() decorator mainly for docs and demo use. 2018-02-13 20:00:13 +05:45
David Wilson 4121e9b35a issue #68: replace sets with lists
Fix a MyPy warning by only passing lists to select.select(). At least on
Python 2.x, select.select() was internally converting the sets to lists
anyway.

By the time lists become inefficient here, it is likely that
select.select() itself will also be inefficient, and need replaced with
.poll() or similar.

No discernible performance different when transferring django.db.models
to a local VM.
2018-02-13 18:49:03 +05:45
David Wilson 6897227a31 utils: support log_to_file(usec=True) 2018-02-13 15:53:18 +05:45
David Wilson 593e6e3261 importer: warn on duplicate request, simplify preload logic
* Children should never generate a request for a module that has already
  been sent, however there are a variety of edge cases where, e.g.
  asynchronous calls are made into unloaded modules in a set of
  children, causing those children to request modules (and deps) in a
  different order, which might break deduplication. So add a warning to
  catch when this happens, so we can figure out how to handle it.
  Meanwhile it's only a warning since in the worst case, this just adds
  needless latency.

* Don't bother treating sent packages separately, there doesn't seem to
  be any need for this (after docs are updated to match how preloading
  actually works now).
2018-02-13 15:49:25 +05:45
David Wilson 8765f761c9 importer: fix glaring bug in find_related()
Overwriting 'fullname' variable caused basically nonsensical filtering.
Result was including the module being searched in the list of
dependencies, which was causing ModuleResponder to send it early, which
was causing contexts to start importing the module before preloading of
dependencies had completed.
2018-02-13 15:47:38 +05:45
David Wilson e3d170904e importer: warn once about missing source and cache negative hit 2018-02-13 15:46:34 +05:45