2016-08-26 18:42:40 +00:00
|
|
|
"""
|
|
|
|
Print the size of a typical SSH command line and the bootstrap code sent to new
|
|
|
|
contexts.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import inspect
|
|
|
|
import zlib
|
|
|
|
|
|
|
|
import econtext.master
|
|
|
|
import econtext.ssh
|
2016-11-01 11:38:24 +00:00
|
|
|
import econtext.sudo
|
2016-08-26 18:42:40 +00:00
|
|
|
|
Introduce econtext.core.Router, refactor everything
* Header now contains (src, dst) context IDs for routing.
* econtext.context_id now contains current process' context ID.
* Now do 16kb-sized reads rather than 4kb.
* econtext package is uniformly imported in econtext/core.py in slave
and master.
* Introduce econtext.core.Message() to centralize pickling policy, and
various function interfaces, may rip it out again later.
* Teach slave/first stage to preserve the copy of econtext.core sent to
it, so that it can be used for subsequent slave-of-slave bootstraps.
* Disconnect Stream from Context, and teach Context to send messages via
Router. In this way the Context class works identically for slaves
directly connected via a Stream, or those for whom other slaves are
acting as proxies.
* Implement Router, which knows a list of contexts reachable via a
Stream. Move context registry out of Broker and into Router.
* Move _invoke crap out of stream and into Context.
* Try to avoid pickling on the Broker thread wherever possible.
* Delete connection-specific fields from Context, they live on the
associated Stream subclass now instead.
* Merge alloc_handle() and add_handle_cb() into add_handler().
* s/enqueue/send/
* Add a hacky guard to prevent send_await() deadlock from Broker thread.
* Temporarily break shutdown logic: graceful shutdown is broken since
Broker doesn't know about which contexts exist any more.
* Handle EIO in iter_read() too. Also need to support ECONNRESET in here.
* Make iter_read() show last 100 bytes on failure.
* econtext.master.connect() is now econtext.master.Router.connect(),
move most of the context/stream construction cutpaste into a single
function, and Stream.construct().
* Stop using sys.executable, since it is the empty string when Python
has been started with a custom argv[0]. Hard-wire python2.7 for now.
* Streams now have names, which are used as the default name for the
associated Context during construction. That way Stream<->Context
association is still fairly obviously and Stream.repr() prints
something nice.
2017-08-22 17:42:22 +00:00
|
|
|
with econtext.master.Broker() as broker:
|
|
|
|
router = econtext.core.Router(broker)
|
|
|
|
context = econtext.master.Context(router, 0)
|
|
|
|
stream = econtext.ssh.Stream(router, 0, context.key, hostname='foo')
|
|
|
|
print 'SSH command size: %s' % (len(' '.join(stream.get_boot_command())),)
|
|
|
|
print 'Preamble size: %s (%.2fKiB)' % (
|
|
|
|
len(stream.get_preamble()),
|
|
|
|
len(stream.get_preamble()) / 1024.0,
|
|
|
|
)
|
2016-08-26 18:42:40 +00:00
|
|
|
|
2016-11-01 11:38:24 +00:00
|
|
|
for mod in (
|
|
|
|
econtext.master,
|
|
|
|
econtext.ssh,
|
|
|
|
econtext.sudo,
|
|
|
|
):
|
|
|
|
sz = len(zlib.compress(econtext.master.minimize_source(inspect.getsource(mod))))
|
|
|
|
print '%s size: %s (%.2fKiB)' % (mod.__name__, sz, sz / 1024.0)
|