Commit Graph

1592 Commits

Author SHA1 Message Date
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
David Wilson 6fc8fa5b22 core: Don't crash if a stream is missing a side. 2018-03-19 21:58:28 +05:45
David Wilson 9238e09ae8 core: Restore behaviour of unpickling Router-specific Context subclass 2018-03-19 21:58:28 +05:45
David Wilson dd088908df select: clean up API. 2018-03-19 21:58:28 +05:45
David Wilson df07e47d24 core: de-munge Message.unpickle() vs. Receiver.get(). 2018-03-19 21:58:28 +05:45
David Wilson a39cd44bf2 core: add auth_id field. 2018-03-19 21:58:28 +05:45
David Wilson a54c96faae core: remove unused SecurityError. 2018-03-19 21:58:28 +05:45
David Wilson 07d4d799f1 Add mitogen.main() decorator mainly for docs and demo use. 2018-03-19 21:58:28 +05:45
David Wilson 55c23e1c57 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-03-19 21:58:28 +05:45
David Wilson 09eb3fd9ba utils: support log_to_file(usec=True) 2018-03-19 21:58:28 +05:45
David Wilson 2848d35aff 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-03-19 21:58:28 +05:45
David Wilson 2e729e54cc 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-03-19 21:58:28 +05:45
David Wilson 0dbb1ec028 importer: warn once about missing source and cache negative hit 2018-03-19 21:58:28 +05:45
David Wilson a0d9d34231 core: fix profiling
* SIGTERM safety net prevents profiler from writing results, so disable
  it when profiling is active.
* fix warning corrupting stream when profiling=True
2018-03-19 21:58:28 +05:45
David Wilson b158259c86 Split up parent and master modules
Knocks 4kb off network footprint for a proxy connection.
2018-03-19 21:58:28 +05:45
David Wilson 5f2fa2cda6 importer: always refuse builtins and __builtin__. 2018-03-19 21:58:28 +05:45
David Wilson 592ebd59c2 docs: reorder sections 2018-03-19 21:58:28 +05:45
David Wilson 0f899f34ff importer: new format to signal ImportError
Previously we'd send just None in GET_MODULE reply, but now since there
is no single request-reply structure, we must include the fullname in
the LOAD_MODULE response and make all of its data fields None to
indicate the same.
2018-03-19 21:58:28 +05:45
David Wilson dee856f6f4 docs: remove obsolete warning 2018-03-19 21:58:28 +05:45
David Wilson 07ae14f11d importer: semi-functional preloader
Doesn't yet implement the rules in the docs, but I think the doc rules
could maybe change to match this. Needs lots of cleanup work and
thorough testing, but this is a great start.
2018-03-19 21:58:28 +05:45
David Wilson b941bce964 docs: sphinx-autobuild default target. 2018-03-19 21:58:28 +05:45
David Wilson 4d9d21c808 docs: fix typo 2018-03-19 21:58:28 +05:45
David Wilson 4a6d55ced6 docs: vastly simplify importer concurrency docs 2018-03-19 21:58:28 +05:45
David Wilson 984b39180e importer: Beginnings of howitworks section. 2018-03-19 21:58:28 +05:45
David Wilson 4d01dc3ba6 Initial pass at module preloading
* Don't implement the rules for when preloading occurs yet
* Don't attempt to streamily preload modules downstream while this
  context hasn't yet received the final module. There is quite
  significant latency buried in here, but for now it's a lot of work to
  fix.

This works well enough to handle at least the mitogen package, but it's
likely broken for anything bigger.
2018-03-19 21:58:28 +05:45
David Wilson 219718740b Move django test script into permanent test 2018-03-19 21:58:28 +05:45
David Wilson b580ada89f Tidy up and correct the new example 2018-03-19 21:58:28 +05:45
David Wilson eb2aef866b Add shell replacement example. 2018-03-19 21:58:28 +05:45
David Wilson b75e77b410 master: force set_block() in tty_create_child too.
For gevent, just as in 5f7633cd56
2018-03-19 21:58:28 +05:45