Artifactspublic-v0

curl

master
ply4 git calls39 ms289 KiB3 cachedprotocol v2
199 lines5.3 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
26#include "uint-table.h"
28#ifdef DEBUGBUILD
29#define CURL_UINT32_TBL_MAGIC 0x62757473
30#endif
32void Curl_uint32_tbl_init(struct uint32_tbl *tbl)
34 memset(tbl, 0, sizeof(*tbl));
35 tbl->last_key_added = UINT32_MAX;
36#ifdef DEBUGBUILD
37 tbl->init = CURL_UINT32_TBL_MAGIC;
38#endif
41static void uint32_tbl_clear_rows(struct uint32_tbl *tbl,
42 uint32_t from,
43 uint32_t upto_excluding)
45 uint32_t i, end;
47 end = CURLMIN(upto_excluding, tbl->nrows);
48 for(i = from; i < end; ++i) {
49 if(tbl->rows[i]) {
50 tbl->rows[i] = NULL;
51 tbl->nentries--;
52 }
53 }
56CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows)
58 /* we use `tbl->nrows + 1` during iteration, want that to work */
59 DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
60 if(!nrows)
61 return CURLE_BAD_FUNCTION_ARGUMENT;
62 if(nrows != tbl->nrows) {
63 void **rows = curlx_calloc(nrows, sizeof(void *));
64 if(!rows)
65 return CURLE_OUT_OF_MEMORY;
66 if(tbl->rows) {
67 memcpy(rows, tbl->rows, (CURLMIN(nrows, tbl->nrows) * sizeof(void *)));
68 if(nrows < tbl->nrows)
69 uint32_tbl_clear_rows(tbl, nrows, tbl->nrows);
70 curlx_free(tbl->rows);
71 }
72 tbl->rows = rows;
73 tbl->nrows = nrows;
74 }
75 return CURLE_OK;
78/* Clear the table, making it empty.
80 @unittest 3212
81 */
82UNITTEST void uint32_tbl_clear(struct uint32_tbl *tbl);
83UNITTEST void uint32_tbl_clear(struct uint32_tbl *tbl)
85 DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
86 uint32_tbl_clear_rows(tbl, 0, tbl->nrows);
87 DEBUGASSERT(!tbl->nentries);
88 tbl->last_key_added = UINT32_MAX;
91void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl)
93 DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
94 uint32_tbl_clear(tbl);
95 curlx_free(tbl->rows);
96 memset(tbl, 0, sizeof(*tbl));
99uint32_t Curl_uint32_tbl_capacity(struct uint32_tbl *tbl)
101 return tbl->nrows;
104uint32_t Curl_uint32_tbl_count(struct uint32_tbl *tbl)
106 return tbl->nentries;
109void *Curl_uint32_tbl_get(struct uint32_tbl *tbl, uint32_t key)
111 return (key < tbl->nrows) ? tbl->rows[key] : NULL;
114bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey)
116 uint32_t key, start_pos;
118 DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
119 if(!entry || !pkey)
120 return FALSE;
121 *pkey = UINT32_MAX;
122 if(tbl->nentries == tbl->nrows) /* full */
123 return FALSE;
125 start_pos = CURLMIN(tbl->last_key_added, tbl->nrows) + 1;
126 for(key = start_pos; key < tbl->nrows; ++key) {
127 if(!tbl->rows[key]) {
128 tbl->rows[key] = entry;
129 tbl->nentries++;
130 tbl->last_key_added = key;
131 *pkey = key;
132 return TRUE;
133 }
134 }
135 /* no free entry at or above tbl->maybe_next_key, wrap around */
136 for(key = 0; key < start_pos; ++key) {
137 if(!tbl->rows[key]) {
138 tbl->rows[key] = entry;
139 tbl->nentries++;
140 tbl->last_key_added = key;
141 *pkey = key;
142 return TRUE;
143 }
144 }
145 /* Did not find any free row? Should not happen */
146 DEBUGASSERT(0);
147 return FALSE;
150void Curl_uint32_tbl_remove(struct uint32_tbl *tbl, uint32_t key)
152 if(key < tbl->nrows)
153 uint32_tbl_clear_rows(tbl, key, key + 1);
156bool Curl_uint32_tbl_contains(struct uint32_tbl *tbl, uint32_t key)
158 return (key < tbl->nrows) ? !!tbl->rows[key] : FALSE;
161static bool uint32_tbl_next_at(struct uint32_tbl *tbl, uint32_t key,
162 uint32_t *pkey, void **pentry)
164 for(; key < tbl->nrows; ++key) {
165 if(tbl->rows[key]) {
166 *pkey = key;
167 *pentry = tbl->rows[key];
168 return TRUE;
169 }
170 }
171 *pkey = UINT32_MAX; /* always invalid */
172 *pentry = NULL;
173 return FALSE;
176bool Curl_uint32_tbl_first(struct uint32_tbl *tbl,
177 uint32_t *pkey, void **pentry)
179 if(!pkey || !pentry)
180 return FALSE;
181 if(tbl->nentries && uint32_tbl_next_at(tbl, 0, pkey, pentry))
182 return TRUE;
183 DEBUGASSERT(!tbl->nentries);
184 *pkey = UINT32_MAX; /* always invalid */
185 *pentry = NULL;
186 return FALSE;
189bool Curl_uint32_tbl_next(struct uint32_tbl *tbl, uint32_t last_key,
190 uint32_t *pkey, void **pentry)
192 if(!pkey || !pentry)
193 return FALSE;
194 if(uint32_tbl_next_at(tbl, last_key + 1, pkey, pentry))
195 return TRUE;
196 *pkey = UINT32_MAX; /* always invalid */
197 *pentry = NULL;
198 return FALSE;
Diagnostics4 git calls · 39 ms
CallStatusSizeTime039 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=1
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 · hit1 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=1
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=1
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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=35
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
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.7 KiB · hit35 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1755
git.response.cache=HIT
git.response.duration_ms=35
git.fetch.wants=71b52999830cddfa9ab69654bf3f1aa4baa280df
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=1755
git.pkt.payload.max=1734
git.sideband.band1.bytes=1733
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
a5e28a194d0dbd4a
Request
7b47c80b…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format