Artifactspublic-v0

curl

master
ply4 git calls283 ms288 KiB2 cachedprotocol v2
53 lines2.0 KiBRaw

Keeping Time

Transfers need the current time to handle timeouts and keep a record of events. The current time function is curlx_now() and it uses a monotonic clock on most platforms. This ensures that time only ever increases (the timestamps it gives are however not the "real" world clock).

Initial Approach (now historic)

The loop processing functions called curlx_now() at the beginning and then passed a pointer to the struct curltime now to functions to save them the calls. Passing this pointer down to all functions possibly involved was not done as this pollutes the internal APIs.

Some functions continued to call curlx_now() on their own while others used the passed pointer to a timestamp in the past. This led to a transfer experiencing jumps in time, reversing cause and effect. On fast systems, this was mostly not noticeable. On slow machines or in CI, this led to rare and annoying test failures.

(Especially when we added assertions that the reported "timeline" of a transfer was in the correct order: queue -> namelookup -> connect -> appconnect ->....)

Revised Approach

The strategy of handling transfer's time is now:

  • Keep a "now" timestamp in the multi handle. Keep a fallback "now" timestamp in the easy handle.
  • Always use Curl_pgrs_now(data) to get the current time of a transfer.
  • Do not use curlx_now() directly for transfer handling (exceptions apply for loops).

This has the following advantages:

  • No need to pass a struct curltime around or pass a pointer to an outdated timestamp to other functions.
  • No need to calculate the exact now until it is really used.
  • Passing a const pointer is better than struct passing. Updating and passing a pointer to the same memory location for all transfers is even better.

Caveats:

  • do not store the pointer returned by Curl_pgrs_now(data) anywhere that outlives the current code invocation.
1<!--
2Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
4SPDX-License-Identifier: curl
5-->
7# Keeping Time
9Transfers need the current time to handle timeouts and keep a record of
10events. The current time function is `curlx_now()` and it uses a **monotonic**
11clock on most platforms. This ensures that time only ever increases (the
12timestamps it gives are however not the "real" world clock).
14## Initial Approach (now historic)
16The loop processing functions called `curlx_now()` at the beginning and then
17passed a pointer to the `struct curltime now` to functions to save them the
18calls. Passing this pointer down to all functions possibly involved was not
19done as this pollutes the internal APIs.
21Some functions continued to call `curlx_now()` on their own while others used
22the passed pointer *to a timestamp in the past*. This led to a transfer
23experiencing *jumps* in time, reversing cause and effect. On fast systems,
24this was mostly not noticeable. On slow machines or in CI, this led to rare
25and annoying test failures.
27(Especially when we added assertions that the reported "timeline" of a
28transfer was in the correct order: *queue -> namelookup -> connect ->
29appconnect ->...*.)
31## Revised Approach
33The strategy of handling transfer's time is now:
35* Keep a "now" timestamp in the multi handle. Keep a fallback "now" timestamp
36 in the easy handle.
37* Always use `Curl_pgrs_now(data)` to get the current time of a transfer.
38* Do not use `curlx_now()` directly for transfer handling (exceptions apply
39 for loops).
41This has the following advantages:
43* No need to pass a `struct curltime` around or pass a pointer to an outdated
44 timestamp to other functions.
45* No need to calculate the exact `now` until it is really used.
46* Passing a `const` pointer is better than struct passing. Updating and
47 passing a pointer to the same memory location for all transfers is even
48 better.
50Caveats:
52* do not store the pointer returned by `Curl_pgrs_now(data)` anywhere that
53 outlives the current code invocation.
Diagnostics4 git calls · 283 ms
CallStatusSizeTime0283 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.1 KiB278 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=278
git.response.bytes=1079
git.response.cache=MISS
git.response.duration_ms=278
git.fetch.wants=4d99d63ce89d040bb5a91f3d2ab7c63fadd10ae1
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1079
git.pkt.payload.max=1058
git.sideband.band1.bytes=1057
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e2fa0f6a5890c0
Request
71a683ce…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format