1
2
3
4
5
6
7
8
9
10
11
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
+
-
+
+
+
-
+
+
+
-
+
+
+
+
|
The goals of this branch are:
- Reduce memory cost of outbound payloads which have a login card by eliminating one of the copies of the payload.
- Keep downstream clients (read as "libfossil") from having to perform the same memory-hungry juggling to generate their sync payloads.
It achieves those by enabling the sync layer's login card to be stored in the HTTP headers instead of in the sync body payload. Specifically, it writes the login card to a transient Cookie header (as distinct from a Set-Cookie header) which compatible remotes will recognize.
It achieves those by enabling the sync layer's login card to be stored as the `X-Fossil-Xfer-Login` header instead of in the sync body payload. The /xfer layer enables this based on client/server version info, and this branch must be able to interact with any older versions for both push and pull operations. (Any deviation from that is a bug.)
The sync workflow typically runs like this:
- Send a message to the server stating our intent, e.g. a push. At this point the client does not know whether the server supports this feature, so it must use the "legacy" login card format. The initial message is typically quite small, so this isn't usually a huge memory cost.
Open issues:
- When the server responds, the client inspects the traffic to see if the remote it supports the new-style login cards. If so, it makes a note of that so that subsequent posts for this same sync will send login cards as a cookie. (The server side of a sync never sends login cards - only the client side does.)
- Make any number of subsequent round-trips. At this point we know whether to use the cookie or not. Using it costs fossil less memory by eliminating an extra copy of the request body which otherwise needed to place the login card properly.
- CGI-hosted fossils do not get the HTTP headers, so cannot use this approach. We can possibly worked around this by passing the card as a URL parameter during sync and handling it early on in fossil like we do `?skin=...`.
Many sync messages are quite small but posting of new files, or large changes, can cost considerable amounts of RAM (e.g. sqlite3.c requires something like 3MB to pack into the sync protocol), and those large packets now cost slightly less than half as much RAM to generate.
Design note: this change initially aimed to use a custom HTTP header, but that was incompatible with CGI-hosted fossils, which do not have access to the raw HTTP headers. Switching to a cookie was [forum:9959d2d9d9be22d2 | suggested in the forum] and it turned out to be much simpler to implement that way.
|