Skip to content

Commit 7b2a2a3

Browse files
authored
perf: add sync benchmark workflow and optimize network apply path (#49)
Add a sync benchmark harness and workflow, improve CloudSync send performance for small payloads by applying them without an upload URL round trip, and reuse curl connections across repeated API requests.
1 parent c509ba5 commit 7b2a2a3

9 files changed

Lines changed: 1278 additions & 46 deletions

File tree

.github/workflows/sync-bench.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: sync benchmark
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
poll_delay_ms:
7+
description: Polling delay between receiver checks, in milliseconds
8+
required: false
9+
default: '250'
10+
max_polls:
11+
description: Maximum number of receiver polling attempts
12+
required: false
13+
default: '40'
14+
curl_pool:
15+
description: Enable curl connection pool; use 0 to disable
16+
required: false
17+
default: '1'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
sync-bench-debug:
24+
name: sync-bench-debug linux x86_64
25+
runs-on: ubuntu-22.04
26+
timeout-minutes: 20
27+
28+
env:
29+
SYNC_BENCH_DATABASE_ID: ${{ secrets.SYNC_BENCH_DATABASE_ID }}
30+
SYNC_BENCH_CLOUDSYNC_ADDRESS: ${{ secrets.SYNC_BENCH_CLOUDSYNC_ADDRESS }}
31+
SYNC_BENCH_APIKEY: ${{ secrets.SYNC_BENCH_APIKEY }}
32+
SYNC_BENCH_OUTPUT: json
33+
SYNC_BENCH_POLL_DELAY_MS: ${{ inputs.poll_delay_ms }}
34+
SYNC_BENCH_MAX_POLLS: ${{ inputs.max_polls }}
35+
CLOUDSYNC_CURL_POOL: ${{ inputs.curl_pool }}
36+
37+
steps:
38+
- uses: actions/checkout@v4.2.2
39+
with:
40+
submodules: true
41+
42+
- name: Install dependencies
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y gcc make curl sqlite3 unzip
46+
47+
- name: Build debug benchmark
48+
run: make SYNC_BENCH_DEBUG=1 extension dist/sync_bench
49+
50+
- name: Run sync benchmark
51+
run: |
52+
mkdir -p artifacts
53+
./dist/sync_bench > artifacts/sync-bench.json 2> artifacts/sync-bench.trace.log
54+
55+
- name: Upload benchmark artifacts
56+
if: always()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: sync-bench-debug-${{ github.run_id }}
60+
path: |
61+
artifacts/sync-bench.json
62+
artifacts/sync-bench.trace.log
63+
if-no-files-found: warn

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [1.0.20] - 2026-05-26
8+
9+
### Changed
10+
11+
- **Improved network sync performance** by reducing request overhead during `cloudsync_network_send_changes()`, especially for small payloads that can now be applied without the extra upload-URL round trip.
12+
- **Improved repeated sync request latency** by allowing the network layer to reuse HTTP connections across CloudSync API calls.
13+
14+
## [1.0.19] - 2026-05-15
15+
16+
### Added
17+
18+
- **Mac Catalyst support**.
19+
720
## [1.0.18] - 2026-04-29
821

922
### Fixed

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ endif
185185
T_LDFLAGS += -fprofile-arcs -ftest-coverage
186186
endif
187187

188+
ifdef SYNC_BENCH_DEBUG
189+
CFLAGS += -DCLOUDSYNC_NETWORK_TRACE
190+
endif
191+
188192
# Native network support only for Apple platforms
189193
ifdef NATIVE_NETWORK
190194
RELEASE_OBJ += $(patsubst %.m, $(BUILD_RELEASE)/%_m.o, $(notdir $(wildcard $(NETWORK_DIR)/*.m)))
@@ -271,6 +275,25 @@ e2e: $(TARGET) $(DIST_DIR)/integration$(EXE)
271275
fi; \
272276
./$(DIST_DIR)/integration$(EXE)
273277

278+
# Run the sync performance benchmark. This is intentionally separate from e2e
279+
# because timings depend on network/server load and polling configuration.
280+
sync-bench: $(TARGET) $(DIST_DIR)/sync_bench$(EXE)
281+
@if [ -f .env ]; then \
282+
export $$(grep -v '^#' .env | xargs); \
283+
fi; \
284+
if [ -n "$(SYNC_BENCH_DATABASE_ID)" ]; then export SYNC_BENCH_DATABASE_ID="$(SYNC_BENCH_DATABASE_ID)"; fi; \
285+
if [ -n "$(SYNC_BENCH_CLOUDSYNC_ADDRESS)" ]; then export SYNC_BENCH_CLOUDSYNC_ADDRESS="$(SYNC_BENCH_CLOUDSYNC_ADDRESS)"; fi; \
286+
if [ -n "$(SYNC_BENCH_APIKEY)" ]; then export SYNC_BENCH_APIKEY="$(SYNC_BENCH_APIKEY)"; fi; \
287+
if [ -n "$(SYNC_BENCH_POLL_DELAY_MS)" ]; then export SYNC_BENCH_POLL_DELAY_MS="$(SYNC_BENCH_POLL_DELAY_MS)"; fi; \
288+
if [ -n "$(SYNC_BENCH_MAX_POLLS)" ]; then export SYNC_BENCH_MAX_POLLS="$(SYNC_BENCH_MAX_POLLS)"; fi; \
289+
if [ -n "$(SYNC_BENCH_RANDOM_BLOB_SIZE_BYTES)" ]; then export SYNC_BENCH_RANDOM_BLOB_SIZE_BYTES="$(SYNC_BENCH_RANDOM_BLOB_SIZE_BYTES)"; fi; \
290+
if [ -n "$(SYNC_BENCH_CLEANUP_OLDER_THAN_SECONDS)" ]; then export SYNC_BENCH_CLEANUP_OLDER_THAN_SECONDS="$(SYNC_BENCH_CLEANUP_OLDER_THAN_SECONDS)"; fi; \
291+
if [ -n "$(SYNC_BENCH_OUTPUT)" ]; then export SYNC_BENCH_OUTPUT="$(SYNC_BENCH_OUTPUT)"; fi; \
292+
./$(DIST_DIR)/sync_bench$(EXE)
293+
294+
sync-bench-debug:
295+
$(MAKE) SYNC_BENCH_DEBUG=1 sync-bench
296+
274297
OPENSSL_TARBALL = $(OPENSSL_DIR)/$(OPENSSL_VERSION).tar.gz
275298

276299
$(OPENSSL_TARBALL):

src/cloudsync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
extern "C" {
1919
#endif
2020

21-
#define CLOUDSYNC_VERSION "1.0.19"
21+
#define CLOUDSYNC_VERSION "1.0.20"
2222
#define CLOUDSYNC_MAX_TABLENAME_LEN 512
2323

2424
#define CLOUDSYNC_VALUE_NOTSET -1

0 commit comments

Comments
 (0)