##// END OF EJS Templates
wireproto: add streams to frame-based protocol...
wireproto: add streams to frame-based protocol Previously, the frame-based protocol was just a series of frames, with each frame associated with a request ID. In order to scale the protocol, we'll want to enable the use of compression. While it is possible to enable compression at the socket/pipe level, this has its disadvantages. The big one is it undermines the point of frames being standalone, atomic units that can be read and written: if you add compression above the framing protocol, you are back to having a stream-based protocol as opposed to something frame-based. So in order to preserve frames, compression needs to occur at the frame payload level. Compressing each frame's payload individually will limit compression ratios because the window size of the compressor will be limited by the max frame size, which is 32-64kb as currently defined. It will also add CPU overhead, as it is more efficient for compressors to operate on fewer, larger blocks of data than more, smaller blocks. So compressing each frame independently is out. This means we need to compress each frame's payload as if it is part of a larger stream. The simplest approach is to have 1 stream per connection. This could certainly work. However, it has disadvantages (documented below). We could also have 1 stream per RPC/command invocation. (This is the model HTTP/2 goes with.) This also has disadvantages. The main disadvantage to one global stream is that it has the very real potential to create CPU bottlenecks doing compression. Networks are only getting faster and the performance of single CPU cores has been relatively flat. Newer compression formats like zstandard offer better CPU cycle efficiency than predecessors like zlib. But it still all too common to saturate your CPU with compression overhead long before you saturate the network pipe. The main disadvantage with streams per request is that you can't reap the benefits of the compression context for multiple requests. For example, if you send 1000 RPC requests (or HTTP/2 requests for that matter), the response to each would have its own compression context. The overall size of the raw responses would be larger because compression contexts wouldn't be able to reference data from another request or response. The approach for streams as implemented in this commit is to support N streams per connection and for streams to potentially span requests and responses. As explained by the added internals docs, this facilitates servers and clients delegating independent streams and compression to independent threads / CPU cores. This helps alleviate the CPU bottleneck of compression. This design also allows compression contexts to be reused across requests/responses. This can result in improved compression ratios and less overhead for compressors and decompressors having to build new contexts. Another feature that was defined was the ability for individual frames within a stream to declare whether that individual frame's payload uses the content encoding (read: compression) defined by the stream. The idea here is that some servers may serve data from a combination of caches and dynamic resolution. Data coming from caches may be pre-compressed. We want to facilitate servers being able to essentially stream bytes from caches to the wire with minimal overhead. Being able to mix and match with frames are compressed within a stream enables these types of advanced server functionality. This commit defines the new streams mechanism. Basic code for supporting streams in frames has been added. But that code is seriously lacking and doesn't fully conform to the defined protocol. For example, we don't close any streams. And support for content encoding within streams is not yet implemented. The change was rather invasive and I didn't think it would be reasonable to implement the entire feature in a single commit. For the record, I would have loved to reuse an existing multiplexing protocol to build the new wire protocol on top of. However, I couldn't find a protocol that offers the performance and scaling characteristics that I desired. Namely, it should support multiple compression contexts to facilitate scaling out to multiple CPU cores and compression contexts should be able to live longer than single RPC requests. HTTP/2 *almost* fits the bill. But the semantics of HTTP message exchange state that streams can only live for a single request-response. We /could/ tunnel on top of HTTP/2 streams and frames with HEADER and DATA frames. But there's no guarantee that HTTP/2 libraries and proxies would allow us to use HTTP/2 streams and frames without the HTTP message exchange semantics defined in RFC 7540 Section 8. Other RPC protocols like gRPC tunnel are built on top of HTTP/2 and thus preserve its semantics of stream per RPC invocation. Even QUIC does this. We could attempt to invent a higher-level stream that spans HTTP/2 streams. But this would be violating HTTP/2 because there is no guarantee that HTTP/2 streams are routed to the same server. The best we can do - which is what this protocol does - is shoehorn all request and response data into a single HTTP message and create streams within. At that point, we've defined a Content-Type in HTTP parlance. It just so happens our media type can also work as a standalone, stream-based protocol, without leaning on HTTP or similar protocol. Differential Revision: https://phab.mercurial-scm.org/D2907

File last commit:

r34950:ff178743 stable
r37304:9bfcbe4f default
Show More
phases.txt
100 lines | 3.0 KiB | text/plain | TextLexer
Matt Mackall
help: add phases topic
r15996 What are phases?
FUJIWARA Katsunori
doc: unify section level between help topics...
r17267 ================
Matt Mackall
help: add phases topic
r15996
Phases are a system for tracking which changesets have been or should
be shared. This helps prevent common mistakes when modifying history
(for instance, with the mq or rebase extensions).
Each changeset in a repository is in one of the following phases:
- public : changeset is visible on a public server
- draft : changeset is not yet published
- secret : changeset should not be pushed, pulled, or cloned
These phases are ordered (public < draft < secret) and no changeset
can be in a lower phase than its ancestors. For instance, if a
changeset is public, all its ancestors are also public. Lastly,
Johan Samyn
help: add verb to sentence in phases.txt
r16244 changeset phases should only be changed towards the public phase.
Matt Mackall
help: add phases topic
r15996
How are phases managed?
FUJIWARA Katsunori
doc: unify section level between help topics...
r17267 =======================
Matt Mackall
help: add phases topic
r15996
For the most part, phases should work transparently. By default, a
changeset is created in the draft phase and is moved into the public
phase when it is pushed to another repository.
Once changesets become public, extensions like mq and rebase will
refuse to operate on them to prevent creating duplicate changesets.
Phases can also be manually manipulated with the :hg:`phase` command
if needed. See :hg:`help -v phase` for examples.
Matt Harbison
help: minor copy editing for grammar
r34950 To make your commits secret by default, put this in your
timeless
phases: mention how to make secret commits in help
r27514 configuration file::
[phases]
new-commit = secret
Matt Mackall
help: add phases topic
r15996 Phases and servers
FUJIWARA Katsunori
doc: unify section level between help topics...
r17267 ==================
Matt Mackall
help: add phases topic
r15996
Normally, all servers are ``publishing`` by default. This means::
- all draft changesets that are pulled or cloned appear in phase
public on the client
- all draft changesets that are pushed appear as public on both
client and server
- secret changesets are neither pushed, pulled, or cloned
.. note::
Simon Heimberg
help: remove last occurrences of ".. note::" without two newlines...
r20532
Matt Mackall
help: add phases topic
r15996 Pulling a draft changeset from a publishing server does not mark it
as public on the server side due to the read-only nature of pull.
Sometimes it may be desirable to push and pull changesets in the draft
phase to share unfinished work. This can be done by setting a
repository to disable publishing in its configuration file::
[phases]
Matt Mackall
help: fix publish option spelling in phases topic
r16000 publish = False
Wagner Bruna
help/phases: remove trailing whitespace
r15998
Jordi Gutiérrez Hermoso
doc: reword "config file" to "configuration file"...
r19295 See :hg:`help config` for more information on configuration files.
Matt Mackall
help: add phases topic
r15996
.. note::
Simon Heimberg
help: remove last occurrences of ".. note::" without two newlines...
r20532
Matt Mackall
help: add phases topic
r15996 Servers running older versions of Mercurial are treated as
publishing.
Pierre-Yves David
phases: add a formal note that hash of secret changeset may leak out...
r20299 .. note::
Simon Heimberg
help: remove last occurrences of ".. note::" without two newlines...
r20532
Pierre-Yves David
phases: add a formal note that hash of secret changeset may leak out...
r20299 Changesets in secret phase are not exchanged with the server. This
applies to their content: file names, file contents, and changeset
metadata. For technical reasons, the identifier (e.g. d825e4025e39)
of the secret changeset may be communicated to the server.
Matt Mackall
help: add examples to phases topic
r16011 Examples
FUJIWARA Katsunori
doc: unify section level between help topics...
r17267 ========
Matt Mackall
help: add examples to phases topic
r16011
- list changesets in draft or secret phase::
hg log -r "not public()"
- change all secret changesets to draft::
hg phase --draft "secret()"
- forcibly move the current changeset and descendants from public to draft::
hg phase --force --draft .
Matt Harbison
help: minor copy editing for grammar
r34950 - show a list of changeset revisions and each corresponding phase::
Matt Mackall
help: add examples to phases topic
r16011
hg log --template "{rev} {phase}\n"
Matt Mackall
phases: add resync example to help topic
r16041 - resynchronize draft changesets relative to a remote repository::
FUJIWARA Katsunori
doc: use double quotation mark to quote arguments in examples for Windows users...
r19959 hg phase -fd "outgoing(URL)"
Matt Mackall
phases: add resync example to help topic
r16041
Matt Mackall
help: add examples to phases topic
r16011 See :hg:`help phase` for more information on manually manipulating phases.