You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 285bc69
Browse filesBrowse the repository at this point in the historyBrowse files
feat(network): drain-all receive with chunk cap; rename to receive_changes
Rework the chunked-download client API for ergonomics and caller control.
- cloudsync_network_sync() now drains an entire chunked /check stream in a
single call, fetching already-available chunks back-to-back with no delay.
wait_ms/max_retries are spent only while the server payload is not yet
ready (HTTP 202), not while paging through chunks already available.
- Add cloudsync_network_receive_changes([max_chunks]) as the canonical
receive function: drains all available chunks by default; max_chunks caps
pages per call for progress/traffic control, resuming across calls via the
in-memory page cursor. cloudsync_network_check_changes() is retained as a
deprecated, fully-functional alias (removed in a future major).
- Add a shared network_drain_changes() helper backing both sync and
receive_changes.
- Surface new JSON fields: receive.chunks/bytes/complete and send.chunks/bytes.
receive.rows and receive.tables are now cumulative across the whole drain.
Docs (API.md, CHANGELOG), integration tests (single-sync drain, capped
receive, and deliberate alias coverage), the sync benchmark, the example
apps, and the .claude command docs are migrated to the new name.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .claude/commands/stress-test-sync-sqlitecloud.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,13 +114,13 @@ Create a bash script at `/tmp/stress_test_concurrent.sh` that:
114
114
- Each iteration does:
115
115
a. **UPDATE** — run `UPDATE <table> SET value = value + 1;` repeated `NUM_UPDATES` times (skip if 0)
116
116
b. **DELETE** — run `DELETE FROM <table> WHERE rowid IN (SELECT rowid FROM <table> ORDER BY RANDOM() LIMIT 10);` repeated `NUM_DELETES` times (skip if 0)
117
-
c. **Sync using the 3-step send/check/check pattern:**
117
+
c. **Sync using the 3-step send/receive/receive pattern:**
118
118
1.`SELECT cloudsync_network_send_changes();` — send local changes to the server
119
-
2.`SELECT cloudsync_network_check_changes();` — ask the server to prepare a payload of remote changes
119
+
2.`SELECT cloudsync_network_receive_changes();` — ask the server to prepare a payload of remote changes
120
120
3. Sleep 1 second (outside sqlite3, between two separate sqlite3 invocations)
121
-
4.`SELECT cloudsync_network_check_changes();` — download the prepared payload, if any
121
+
4.`SELECT cloudsync_network_receive_changes();` — download the prepared payload, if any
122
122
- Each sqlite3 session must: `.load` the extension, call `cloudsync_network_init()`/`cloudsync_network_init_custom()`, `cloudsync_network_set_apikey()`/`cloudsync_network_set_token()` (depending on RLS mode), do the work, call `cloudsync_terminate()`
123
-
-**Timing**: Log the wall-clock execution time (in milliseconds) for each `cloudsync_network_send_changes()`, `cloudsync_network_check_changes()` call. Define a `now_ms()` helper function at the top of the script and use it before and after each sqlite3 invocation that calls a network function, computing the delta. On **macOS**, `date` does not support `%3N` (nanoseconds) — use `python3 -c 'import time; print(int(time.time()*1000))'` instead. On **Linux**, `date +%s%3N` works fine. The script should detect the platform and define `now_ms()` accordingly. Log lines like: `[DB<N>][iter <I>] send_changes: 123ms`, `[DB<N>][iter <I>] check_changes_1: 45ms`, `[DB<N>][iter <I>] check_changes_2: 67ms`
123
+
-**Timing**: Log the wall-clock execution time (in milliseconds) for each `cloudsync_network_send_changes()`, `cloudsync_network_receive_changes()` call. Define a `now_ms()` helper function at the top of the script and use it before and after each sqlite3 invocation that calls a network function, computing the delta. On **macOS**, `date` does not support `%3N` (nanoseconds) — use `python3 -c 'import time; print(int(time.time()*1000))'` instead. On **Linux**, `date +%s%3N` works fine. The script should detect the platform and define `now_ms()` accordingly. Log lines like: `[DB<N>][iter <I>] send_changes: 123ms`, `[DB<N>][iter <I>] receive_changes_1: 45ms`, `[DB<N>][iter <I>] receive_changes_2: 67ms`
124
124
- Include labeled output lines like `[DB<N>][iter <I>] updated count=<C>, deleted count=<D>` for grep-ability
125
125
126
126
3.**Launches all workers in parallel** using `&` and collects PIDs
@@ -138,7 +138,7 @@ Create a bash script at `/tmp/stress_test_concurrent.sh` that:
138
138
- Use `echo -e` to pipe generated SQL (with `\n` separators) into sqlite3
139
139
- During database initialization (Step 1), insert `ROWS` initial rows per database in a single transaction so each DB starts with data to update/delete. Row IDs should be unique across databases: `db<N>_r<J>`
140
140
- User IDs for rows must match the token's userId for RLS to work
141
-
- The sync pattern requires **separate sqlite3 invocations** for send_changes and each check_changes call (with a 1-second sleep between the two check_changes calls), so that timing can be measured per-call from bash
141
+
- The sync pattern requires **separate sqlite3 invocations** for send_changes and each receive_changes call (with a 1-second sleep between the two receive_changes calls), so that timing can be measured per-call from bash
142
142
-**stderr capture**: All sqlite3 invocations must redirect both stdout and stderr to the log file. Use `>> "$LOG" 2>&1` (in this order — stdout redirect first, then stderr to stdout). For timed calls that capture output in a variable, redirect stderr to the log file separately: `RESULT=$(echo -e "$SQL" | $SQLITE3 "$DB" 2>> "$LOG")` and then echo `$RESULT` to the log as well. This ensures "Runtime error" messages from sqlite3 are never lost.
143
143
- Use `/bin/bash` (not `/bin/sh`) for arrays and process management
144
144
@@ -191,7 +191,7 @@ Report the test results including:
191
191
| Rows per iteration | ROWS |
192
192
| Iterations per database | ITERATIONS |
193
193
| Total CRUD operations | N × ITERATIONS × (UPDATE_ALL + DELETE_FEW) |
194
-
| Total sync operations | N × ITERATIONS × 3 (1 send_changes + 2 check_changes) |
194
+
| Total sync operations | N × ITERATIONS × 3 (1 send_changes + 2 receive_changes) |
0 commit comments