Skip to content

Commit ba2f5df

Browse files
committed
feat: tune fast-lane sync benchmark
Raise the inline apply fast-lane payload limit to 128 KiB. Add a configurable random BLOB payload to sync-bench inserts with a 100 KiB default and replicated BLOB verification. Clean up old sync-bench rows before measured inserts and report cleanup retention and delete counts. Include request byte counts in network receive and upload trace logs.
1 parent 7d260d9 commit ba2f5df

5 files changed

Lines changed: 141 additions & 32 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ sync-bench: $(TARGET) $(DIST_DIR)/sync_bench$(EXE)
252252
if [ -n "$(SYNC_BENCH_APIKEY)" ]; then export SYNC_BENCH_APIKEY="$(SYNC_BENCH_APIKEY)"; fi; \
253253
if [ -n "$(SYNC_BENCH_POLL_DELAY_MS)" ]; then export SYNC_BENCH_POLL_DELAY_MS="$(SYNC_BENCH_POLL_DELAY_MS)"; fi; \
254254
if [ -n "$(SYNC_BENCH_MAX_POLLS)" ]; then export SYNC_BENCH_MAX_POLLS="$(SYNC_BENCH_MAX_POLLS)"; fi; \
255+
if [ -n "$(SYNC_BENCH_RANDOM_BLOB_SIZE_BYTES)" ]; then export SYNC_BENCH_RANDOM_BLOB_SIZE_BYTES="$(SYNC_BENCH_RANDOM_BLOB_SIZE_BYTES)"; fi; \
256+
if [ -n "$(SYNC_BENCH_CLEANUP_OLDER_THAN_SECONDS)" ]; then export SYNC_BENCH_CLEANUP_OLDER_THAN_SECONDS="$(SYNC_BENCH_CLEANUP_OLDER_THAN_SECONDS)"; fi; \
255257
if [ -n "$(SYNC_BENCH_OUTPUT)" ]; then export SYNC_BENCH_OUTPUT="$(SYNC_BENCH_OUTPUT)"; fi; \
256258
./$(DIST_DIR)/sync_bench$(EXE)
257259

src/network/network.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static size_t cacert_len = sizeof(cacert_pem) - 1;
5757
#define CLOUDSYNC_CURL_MAXLIFETIME_CONN_SECONDS 60L
5858
#endif
5959
#ifndef CLOUDSYNC_NETWORK_FAST_LANE_MAX_BLOB_SIZE
60-
#define CLOUDSYNC_NETWORK_FAST_LANE_MAX_BLOB_SIZE (32 * 1024)
60+
#define CLOUDSYNC_NETWORK_FAST_LANE_MAX_BLOB_SIZE (128 * 1024)
6161
#endif
6262

6363
#define DEFAULT_SYNC_WAIT_MS 100
@@ -122,15 +122,15 @@ const char *network_trace_result_name(int code) {
122122
}
123123
}
124124

125-
void network_trace_log(network_data *data, const char *method, const char *endpoint, long http_status, int result_code, size_t bytes, double elapsed_ms) {
125+
void network_trace_log(network_data *data, const char *method, const char *endpoint, long http_status, int result_code, size_t request_bytes, size_t bytes, double elapsed_ms) {
126126
fprintf(stderr,
127-
"[cloudsync-network] endpoint=%s method=%s http_status=%ld result=%s bytes=%zu elapsed_ms=%.2f\n",
127+
"[cloudsync-network] endpoint=%s method=%s http_status=%ld result=%s request_bytes=%zu bytes=%zu elapsed_ms=%.2f\n",
128128
network_trace_endpoint_name(data, endpoint), method, http_status,
129-
network_trace_result_name(result_code), bytes, elapsed_ms);
129+
network_trace_result_name(result_code), request_bytes, bytes, elapsed_ms);
130130
}
131131

132132
#ifndef CLOUDSYNC_OMIT_CURL
133-
void network_trace_log_curl(network_data *data, const char *method, const char *endpoint, long http_status, int result_code, size_t bytes, CURL *curl, bool pooled, double elapsed_ms) {
133+
void network_trace_log_curl(network_data *data, const char *method, const char *endpoint, long http_status, int result_code, size_t request_bytes, size_t bytes, CURL *curl, bool pooled, double elapsed_ms) {
134134
double namelookup = 0.0;
135135
double connect = 0.0;
136136
double appconnect = 0.0;
@@ -146,10 +146,10 @@ void network_trace_log_curl(network_data *data, const char *method, const char *
146146
curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &num_connects);
147147
}
148148
fprintf(stderr,
149-
"[cloudsync-network] endpoint=%s method=%s pool=%s http_status=%ld result=%s bytes=%zu elapsed_ms=%.2f curl_total_ms=%.2f dns_ms=%.2f connect_ms=%.2f tls_ms=%.2f starttransfer_ms=%.2f num_connects=%ld\n",
149+
"[cloudsync-network] endpoint=%s method=%s pool=%s http_status=%ld result=%s request_bytes=%zu bytes=%zu elapsed_ms=%.2f curl_total_ms=%.2f dns_ms=%.2f connect_ms=%.2f tls_ms=%.2f starttransfer_ms=%.2f num_connects=%ld\n",
150150
network_trace_endpoint_name(data, endpoint), method,
151151
pooled ? "on" : "off", http_status,
152-
network_trace_result_name(result_code), bytes, elapsed_ms,
152+
network_trace_result_name(result_code), request_bytes, bytes, elapsed_ms,
153153
total * 1000.0, namelookup * 1000.0, connect * 1000.0,
154154
appconnect * 1000.0, starttransfer * 1000.0, num_connects);
155155
}
@@ -468,6 +468,7 @@ NETWORK_RESULT network_receive_buffer (network_data *data, const char *endpoint,
468468
#endif
469469
#ifdef CLOUDSYNC_NETWORK_TRACE
470470
double trace_start_ms = network_trace_now_ms();
471+
size_t request_bytes = json_payload ? strlen(json_payload) : 0;
471472
#endif
472473

473474
CURL *curl = network_curl_for_endpoint(data, endpoint, &pooled);
@@ -576,7 +577,7 @@ NETWORK_RESULT network_receive_buffer (network_data *data, const char *endpoint,
576577
"[cloudsync-network] endpoint=%s using_ticket=%s\n",
577578
network_trace_endpoint_name(data, endpoint),
578579
using_ticket ? "true" : "false");
579-
network_trace_log_curl(data, method, endpoint, response_code, result.code, result.blen, curl, pooled, network_trace_now_ms() - trace_start_ms);
580+
network_trace_log_curl(data, method, endpoint, response_code, result.code, request_bytes, result.blen, curl, pooled, network_trace_now_ms() - trace_start_ms);
580581
#endif
581582
if (curl && !pooled) curl_easy_cleanup(curl);
582583
return result;
@@ -685,6 +686,7 @@ bool network_send_buffer (network_data *data, const char *endpoint, const char *
685686
#ifdef CLOUDSYNC_NETWORK_TRACE
686687
network_trace_log_curl(data, "PUT", endpoint, response_code,
687688
result ? CLOUDSYNC_NETWORK_OK : CLOUDSYNC_NETWORK_ERROR,
689+
(size_t)blob_size,
688690
result ? (size_t)blob_size : 0,
689691
curl, pooled, network_trace_now_ms() - trace_start_ms);
690692
#endif

src/network/network.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bool network_send_buffer(network_data *data, const char *endpoint, const char *a
2121
NSURL *url = [NSURL URLWithString:urlString];
2222
if (!url) {
2323
#ifdef CLOUDSYNC_NETWORK_TRACE
24-
network_trace_log(data, "PUT", endpoint, 0, CLOUDSYNC_NETWORK_ERROR, 0, network_trace_now_ms() - trace_start_ms);
24+
network_trace_log(data, "PUT", endpoint, 0, CLOUDSYNC_NETWORK_ERROR, (size_t)blob_size, 0, network_trace_now_ms() - trace_start_ms);
2525
#endif
2626
return false;
2727
}
@@ -69,6 +69,7 @@ bool network_send_buffer(network_data *data, const char *endpoint, const char *a
6969
#ifdef CLOUDSYNC_NETWORK_TRACE
7070
network_trace_log(data, "PUT", endpoint, (long)statusCode,
7171
success ? CLOUDSYNC_NETWORK_OK : CLOUDSYNC_NETWORK_ERROR,
72+
(size_t)blob_size,
7273
success ? (size_t)blob_size : 0,
7374
network_trace_now_ms() - trace_start_ms);
7475
#endif
@@ -80,6 +81,7 @@ bool network_send_buffer(network_data *data, const char *endpoint, const char *a
8081
NETWORK_RESULT network_receive_buffer(network_data *data, const char *endpoint, const char *authentication, bool zero_terminated, bool is_post_request, char *json_payload, const char **extra_headers, int nextra_headers) {
8182
#ifdef CLOUDSYNC_NETWORK_TRACE
8283
double trace_start_ms = network_trace_now_ms();
84+
size_t request_bytes = json_payload ? strlen(json_payload) : 0;
8385
#endif
8486
const char *method = (json_payload || is_post_request) ? "POST" : "GET";
8587
bool using_ticket = network_data_should_use_ticket(data, endpoint, authentication);
@@ -97,7 +99,7 @@ NETWORK_RESULT network_receive_buffer(network_data *data, const char *endpoint,
9799
result.xdata = (void *)CFBridgingRetain(msg);
98100
result.xfree = network_buffer_cleanup;
99101
#ifdef CLOUDSYNC_NETWORK_TRACE
100-
network_trace_log(data, method, endpoint, 0, result.code, 0, network_trace_now_ms() - trace_start_ms);
102+
network_trace_log(data, method, endpoint, 0, result.code, request_bytes, 0, network_trace_now_ms() - trace_start_ms);
101103
#endif
102104
return result;
103105
}
@@ -189,7 +191,7 @@ NETWORK_RESULT network_receive_buffer(network_data *data, const char *endpoint,
189191
"[cloudsync-network] endpoint=%s using_ticket=%s\n",
190192
network_trace_endpoint_name(data, endpoint),
191193
using_ticket ? "true" : "false");
192-
network_trace_log(data, method, endpoint, (long)statusCode, result.code, 0, network_trace_now_ms() - trace_start_ms);
194+
network_trace_log(data, method, endpoint, (long)statusCode, result.code, request_bytes, 0, network_trace_now_ms() - trace_start_ms);
193195
#endif
194196
return result;
195197
}
@@ -203,7 +205,7 @@ NETWORK_RESULT network_receive_buffer(network_data *data, const char *endpoint,
203205
NSString *msg = @"Response is not valid UTF-8";
204206
NETWORK_RESULT error_result = {CLOUDSYNC_NETWORK_ERROR, (char *)msg.UTF8String, 0, (void *)CFBridgingRetain(msg), network_buffer_cleanup};
205207
#ifdef CLOUDSYNC_NETWORK_TRACE
206-
network_trace_log(data, method, endpoint, (long)statusCode, error_result.code, 0, network_trace_now_ms() - trace_start_ms);
208+
network_trace_log(data, method, endpoint, (long)statusCode, error_result.code, request_bytes, 0, network_trace_now_ms() - trace_start_ms);
207209
#endif
208210
return error_result;
209211
}
@@ -221,7 +223,7 @@ NETWORK_RESULT network_receive_buffer(network_data *data, const char *endpoint,
221223
"[cloudsync-network] endpoint=%s using_ticket=%s\n",
222224
network_trace_endpoint_name(data, endpoint),
223225
using_ticket ? "true" : "false");
224-
network_trace_log(data, method, endpoint, (long)statusCode, result.code, result.blen, network_trace_now_ms() - trace_start_ms);
226+
network_trace_log(data, method, endpoint, (long)statusCode, result.code, request_bytes, result.blen, network_trace_now_ms() - trace_start_ms);
225227
#endif
226228
return result;
227229
}
@@ -251,7 +253,7 @@ NETWORK_RESULT network_receive_buffer(network_data *data, const char *endpoint,
251253
"[cloudsync-network] endpoint=%s using_ticket=%s\n",
252254
network_trace_endpoint_name(data, endpoint),
253255
using_ticket ? "true" : "false");
254-
network_trace_log(data, method, endpoint, (long)statusCode, result.code, 0, network_trace_now_ms() - trace_start_ms);
256+
network_trace_log(data, method, endpoint, (long)statusCode, result.code, request_bytes, 0, network_trace_now_ms() - trace_start_ms);
255257
#endif
256258
return result;
257259
}

src/network/network_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ NETWORK_RESULT network_receive_buffer (network_data *data, const char *endpoint,
4949
#ifdef CLOUDSYNC_NETWORK_TRACE
5050
const char *network_trace_endpoint_name(network_data *data, const char *endpoint);
5151
const char *network_trace_result_name(int code);
52-
void network_trace_log(network_data *data, const char *method, const char *endpoint, long http_status, int result_code, size_t bytes, double elapsed_ms);
52+
void network_trace_log(network_data *data, const char *method, const char *endpoint, long http_status, int result_code, size_t request_bytes, size_t bytes, double elapsed_ms);
5353
double network_trace_now_ms(void);
5454
#endif
5555

0 commit comments

Comments
 (0)