Artifactspublic-v0

curl

master
ply4 git calls28 ms289 KiB3 cachedprotocol v2
226 lines6.6 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 "urldata.h"
27#include "bufq.h"
28#include "cfilters.h"
29#include "sendf.h"
30#include "curl_trc.h"
31#include "cw-pause.h"
34/* body dynbuf sizes */
35#define CW_PAUSE_BUF_CHUNK (16 * 1024)
36/* when content decoding, write data in chunks */
37#define CW_PAUSE_DEC_WRITE_CHUNK 4096
39struct cw_pause_buf {
40 struct cw_pause_buf *next;
41 struct bufq b;
42 int type;
43};
45static struct cw_pause_buf *cw_pause_buf_create(int type, size_t buflen)
47 struct cw_pause_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf));
48 if(cwbuf) {
49 cwbuf->type = type;
50 if(type & CLIENTWRITE_BODY)
51 Curl_bufq_init2(&cwbuf->b, CW_PAUSE_BUF_CHUNK, 1,
52 (BUFQ_OPT_SOFT_LIMIT | BUFQ_OPT_NO_SPARES));
53 else
54 Curl_bufq_init(&cwbuf->b, buflen, 1);
55 }
56 return cwbuf;
59static void cw_pause_buf_free(struct cw_pause_buf *cwbuf)
61 if(cwbuf) {
62 Curl_bufq_free(&cwbuf->b);
63 curlx_free(cwbuf);
64 }
67struct cw_pause_ctx {
68 struct Curl_cwriter super;
69 struct cw_pause_buf *buf;
70 struct cw_pause_buf *tail;
71 size_t buf_total;
72};
74static CURLcode cw_pause_init(struct Curl_easy *data,
75 struct Curl_cwriter *writer)
77 struct cw_pause_ctx *ctx = writer->ctx;
78 (void)data;
79 ctx->buf = NULL;
80 ctx->tail = NULL;
81 return CURLE_OK;
84static void cw_pause_bufs_free(struct cw_pause_ctx *ctx)
86 while(ctx->buf) {
87 struct cw_pause_buf *next = ctx->buf->next;
88 cw_pause_buf_free(ctx->buf);
89 ctx->buf = next;
90 }
91 ctx->tail = NULL;
94static void cw_pause_close(struct Curl_easy *data, struct Curl_cwriter *writer)
96 struct cw_pause_ctx *ctx = writer->ctx;
98 (void)data;
99 cw_pause_bufs_free(ctx);
102static CURLcode cw_pause_flush(struct Curl_easy *data,
103 struct Curl_cwriter *cw_pause, bool eos)
105 struct cw_pause_ctx *ctx = (struct cw_pause_ctx *)cw_pause;
106 CURLcode result = CURLE_OK;
108 /* write the front of the chain until it blocks or gets empty */
109 while(ctx->buf && !Curl_cwriter_is_paused(data)) {
110 struct cw_pause_buf *first = ctx->buf;
111 size_t blen, wlen = 0;
112 const unsigned char *buf = NULL;
114 if(Curl_bufq_peek(&first->b, &buf, &blen)) {
115 int wtype = first->type;
116 wlen = (first->type & CLIENTWRITE_BODY) ?
117 CURLMIN(blen, CW_PAUSE_DEC_WRITE_CHUNK) : blen;
118 /* EOS only goes with the very last piece, same as in cw_pause_write */
119 if((wlen < Curl_bufq_len(&first->b)) || first->next)
120 wtype &= ~CLIENTWRITE_EOS;
121 result = Curl_cwriter_write(data, cw_pause->next, wtype,
122 (const char *)buf, wlen);
123 CURL_TRC_WRITE(data, "[PAUSE] flushed %zu/%zu bytes, type=%x -> %d",
124 wlen, ctx->buf_total, (unsigned int)wtype,
125 (int)result);
126 Curl_bufq_skip(&first->b, wlen);
127 DEBUGASSERT(ctx->buf_total >= wlen);
128 ctx->buf_total -= wlen;
129 if(result)
130 return result;
131 }
132 else if(first->type & CLIENTWRITE_EOS) {
133 result = Curl_cwriter_write(data, cw_pause->next, first->type,
134 (const char *)buf, 0);
135 CURL_TRC_WRITE(data, "[PAUSE] flushed 0/%zu bytes, type=%x -> %d",
136 ctx->buf_total, (unsigned int)first->type,
137 (int)result);
138 }
140 if(Curl_bufq_is_empty(&first->b)) {
141 ctx->buf = first->next;
142 if(!ctx->buf)
143 ctx->tail = NULL;
144 cw_pause_buf_free(first);
145 }
146 }
148 if(!result)
149 result = Curl_cwriter_flush(data, cw_pause->next, eos && !ctx->buf);
150 return result;
153static CURLcode cw_pause_write(struct Curl_easy *data,
154 struct Curl_cwriter *writer, int type,
155 const char *buf, size_t blen)
157 struct cw_pause_ctx *ctx = writer->ctx;
158 CURLcode result = CURLE_OK;
159 size_t wlen = 0;
161 if(ctx->buf && !Curl_cwriter_is_paused(data)) {
162 result = cw_pause_flush(data, writer, FALSE);
163 if(result)
164 return result;
165 }
167 while(!ctx->buf && !Curl_cwriter_is_paused(data)) {
168 int wtype = type;
169 DEBUGASSERT(!ctx->buf);
170 /* content decoding might blow up size considerably, write smaller
171 * chunks to make pausing need buffer less. */
172 wlen = (type & CLIENTWRITE_BODY) ?
173 CURLMIN(blen, CW_PAUSE_DEC_WRITE_CHUNK) : blen;
174 if(wlen < blen)
175 wtype &= ~CLIENTWRITE_EOS;
176 result = Curl_cwriter_write(data, writer->next, wtype, buf, wlen);
177 if(result)
178 return result;
179 buf += wlen;
180 blen -= wlen;
181 if(!blen)
182 return result;
183 }
185 do {
186 size_t nwritten = 0;
187 if(ctx->tail && (ctx->tail->type == type) && (type & CLIENTWRITE_BODY)) {
188 /* same type and body, append to tail buffer which has a soft
189 * limit and should take everything up to OOM. */
190 result = Curl_bufq_cwrite(&ctx->tail->b, buf, blen, &nwritten);
191 }
192 else {
193 /* Need a new buf, type changed */
194 struct cw_pause_buf *cwbuf = cw_pause_buf_create(type, blen);
195 if(!cwbuf)
196 return CURLE_OUT_OF_MEMORY;
197 if(ctx->tail)
198 ctx->tail->next = cwbuf;
199 else
200 ctx->buf = cwbuf;
201 ctx->tail = cwbuf;
202 result = Curl_bufq_cwrite(&ctx->tail->b, buf, blen, &nwritten);
203 }
204 CURL_TRC_WRITE(data, "[PAUSE] buffer %zu more bytes of type %x, "
205 "total=%zu -> %d", nwritten, (unsigned int)type,
206 ctx->buf_total + wlen, (int)result);
207 if(result)
208 return result;
209 buf += nwritten;
210 blen -= nwritten;
211 ctx->buf_total += nwritten;
212 } while(blen);
214 return result;
217const struct Curl_cwtype Curl_cwt_pause = {
218 "cw-pause",
219 NULL,
220 0,
221 cw_pause_init,
222 cw_pause_write,
223 cw_pause_flush,
224 cw_pause_close,
225 sizeof(struct cw_pause_ctx)
226};
Diagnostics4 git calls · 28 ms
CallStatusSizeTime028 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
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 · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
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=23
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
fetch2002.2 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=2296
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=aaad3efbdcffe6f3bdc12580f09f603ee29aaa37
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=2296
git.pkt.payload.max=2275
git.sideband.band1.bytes=2274
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
a5e14b8e8b8ca140
Request
5f061498…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format