Commit Graph

82 Commits (a031f927d4508a4c480c18eac014ca3ca0b1029d)

Author SHA1 Message Date
David Wilson a031f927d4 importer: share blacklist logic between master/parent 8 years ago
David Wilson 68b34fa8f2 importer: module whitelist/blacklist support
Hoped to avoid it, but it's the obvious solution for Ansible.
8 years ago
David Wilson 0d57afc914 master: use queue-like Latch in Select() too. 8 years ago
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.
8 years ago
David Wilson bb662a1a0b master: helper functions to force disconnect everything 8 years ago
David Wilson 424879dfb4 core: Message.reply() helper function 8 years ago
David Wilson 8ef87bea6a select: clean up API. 8 years ago
David Wilson adc8fe3aed core: de-munge Message.unpickle() vs. Receiver.get(). 8 years ago
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).
8 years ago
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.
8 years ago
David Wilson e3d170904e importer: warn once about missing source and cache negative hit 8 years ago
David Wilson 4d31300dd0 Split up parent and master modules
Knocks 4kb off network footprint for a proxy connection.
8 years ago
David Wilson 0a2a483298 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.
8 years ago
David Wilson 6715a1b150 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.
8 years ago
David Wilson f44356af32 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.
8 years ago
David Wilson e06111d944 master: force set_block() in tty_create_child too.
For gevent, just as in 5f7633cd56
8 years ago
David Wilson 5f7633cd56 master: make mitogen minimally functional under gevent
It seems gevent automatically sets blocking behaviour on fds produced by
the socket module, which causes the Python process we fork to fail
horribly. So in the child, always reset the blocking flag.
8 years ago
David Wilson c503706f96 master: add comment 8 years ago
David Wilson 086c8044a2 master: add a comment to explain what's going on, and fix log msg.
Closes #70
8 years ago
David Wilson e88f9a521f issue #70: remove redundant 'raise SystemExit'
Either execvp succeeds, in which case the process image is replaced, or
execvp throws an exception, in which case control flow exits the frame
anyway.
8 years ago
David Wilson f2e23fb7e0 Add license text everywhere. 8 years ago
David Wilson 22c1594f04 Simplify the API, make Broker optional and auto-shutdown on main thread exit. 8 years ago
David Wilson a01c929d76 Fix Python 3 fix :/ closes #57 8 years ago
David Wilson dacc57ba5f master: Lazy-format more logging arguments, minor 3.x compat increments 8 years ago
Alex Willmer a8dcd53ccc first stage: Remove/dedent else block
Since the above if block ends in a call to os.execv() this block will
only ever run when the if condition was false. Hence putting it in an
else clause is unnecessary.
8 years ago
Alex Willmer 8c085d1ea6 first stage: Use string concatenation 8 years ago
Alex Willmer 0ab6faa8b8 first stage: eliminate whitespace 8 years ago
Alex Willmer 9ee1d13270 first stage: single letter variables 8 years ago
David Wilson 58e30cd117 issue #49: 2.x/3.x compatible decode.
Much uglier command line, but it works across major Python releases.
8 years ago
David Wilson cfb8a38977 Implement Alex's awesome idea of zlibbing the first stage too! Closes #49 8 years ago
David Wilson c83d86f050 importer: Delete _get_module_via_parent entirely
Can't figure out what it's supposed to do any more, and can't find a
version of Ansible before August 2016 (when I wrote that code) that
seems to need it.

Add some more mitigations to avoid sending dylibs.
8 years ago
David Wilson 8439e889ed core: More robust shutdown
Now there is a separate SHUTDOWN message that relies only on being
received by the broker thread, the main thread can be hung horribly and
the process will still eventually receive a SIGTERM.
8 years ago
David Wilson eac5daf28d Fix select_test failure, remove crap old timing_test. 8 years ago
David Wilson eb6afee514 Beginnings of module_finder_test 8 years ago
David Wilson b0e13fefdd Fix 2 call_function_test failures. 8 years ago
David Wilson 0e51aa5cd9 master: hack to avoid executing __main__. 8 years ago
David Wilson 5a71c38fdc We don't support sets, so don't use them in module loader(!) 8 years ago
David Wilson c9e3fbb483 add missing IOLOG, fixes _iter_read/SshTest. 8 years ago
David Wilson 5584dba441 master: include related modules in ModuleResponder response 8 years ago
David Wilson a18ca0f208 iter_read: also treat 0-byte read as disconnection 8 years ago
David Wilson 46c361d4e1 select: fix typo 8 years ago
David Wilson f57a12b3f9 Fix context naming for sudo and via=. 8 years ago
David Wilson 3a883d79f6 More API documentation. 8 years ago
David Wilson 62c9dc6f49 Better document Router API and constructors. 8 years ago
David Wilson 839a1cbeb1 receiver: only permit one notify callback
There is no point spamming a list for every function call, there is no
use case where multiple notify callbacks would be useful.
8 years ago
David Wilson 9e2c74eebc importer: Don't respond to non-.py[co] imports. 8 years ago
David Wilson 186d823600 issue #20: tests and fixes for mitogen.master.Select(). 8 years ago
David Wilson 6869292738 issue #20: initial implementation of mitogen.master.Select(). 8 years ago
David Wilson 1bb4a32271 issue #9: log warning when a cross-sibling CALL_FUNCTION occurs
First step to making it a fatal error.
8 years ago
David Wilson 88d01c571f Adjust get_boot_command to match _first_stage change
inspect module includes the staticmethod decorator added by
a8d1dc6730
8 years ago