Repository navigation
fix(metrics): bound latency segment memory by summing into fixed time buckets - #398
Conversation
… keeping one point per request MetricsCollector kept a SegmentPoint (112 bytes plus two heap strings) for every data-plane request for 24 hours. At 274 requests per second that is 23.7 million points a day and about 4.3 GiB of anonymous memory (issue #397); measured here, the 0.1.13 binary grows by 193.5 bytes per GetItem. The console only reads per-operation counts and mean segments over a window, so the points are summed at record time instead. Each operation now owns two fixed rings of 64-byte buckets: 301 one-second buckets serving LastMinute and Last5Minutes, and 1441 one-minute buckets serving LastHour, LastDay and AllTime. A record is one hash lookup and two bucket updates under the write lock; the rings are allocated once per operation. Memory is at most operations * 111,488 bytes, and the server only records the 37 operations in the dispatch table, so under 4 MiB per process. A window of W seconds covers at least the last W seconds and at most W plus one bucket width. The clock is read under the lock on both the record and the query path, so a stored record is never ahead of a query that follows it. prune() no longer touches segments. record_segments(operation, &LatencySegments) no longer takes the table name: a per-table dimension would multiply the bound by the table count, which clients control, and nothing read it. The one caller is updated. Docs: the design doc states the bucket widths and what each window returns; the deployment guide gains a Process Memory subsection with the growth law for releases through 0.1.13; the todo-index entry for the table field is removed. Tests: boundedness over five million synthetic requests, a naive-reference comparison on a random workload, continuous load across three laps of the coarse ring against a closed-form reference, window filters at second and minute boundaries, ring wrap and stale-slot exclusion, and an ignored timing comparison of the old push against the new record.
Main gave the latency segments an account dimension. record_segments takes the account of the request, and query_segments takes an account filter that /metrics and the console pass. This branch replaced the one-point-per-request vector with fixed time buckets per operation. After the merge the bucket store has two keys: the account, then the operation. A query with an account reads that account's buckets. A query without one sums every account's buckets per operation. It answers what main answered over every account's points, bucketed as this branch buckets them. crates/core/src/metrics/collector.rs keeps the bucket store from this branch and the account argument of record_segments from main. The SegmentPoint struct goes. The account lives in the store's key. crates/core/src/metrics/collector_query.rs keeps the bucket query from this branch and the account filter argument of query_segments from main. Main's rule that an empty account is no filter stays. crates/core/src/metrics/mod.rs keeps the collector_record module from main and the segments module from this branch. crates/server/src/handler.rs keeps the account argument from main and the borrowed segments from this branch. The table name is not passed, as on this branch. crates/core/src/metrics/segments.rs did not conflict and gains the account key. Its tests, main's account filter test in collector_tests.rs and main's console metrics page test in crates/server/src/console/pages/metrics_pages_tests.rs call the new signatures.
Main filters the latency segments by account, so the bucket store has two keys: the account, then the operation. The bound test records under three accounts and expects accounts x operations x 1,742 buckets. The random workload test gives each point an account. It checks the answer without a filter against every account's points, and the answer with each account's filter against that account's points. The sort test checks that an account that sent nothing reads empty.
Main filters the latency segments by account, so the bucket store has two keys, the account and the operation, and its bound is per account. The metrics section of the server design doc and the process memory section of the deployment guide now give the bound. It is accounts x operations x 111,488 bytes. With the 40 operations the server dispatches that is 4,459,520 bytes (4.25 MiB) for each account that sends a request. The bound grows with the accounts that send requests and not with the request rate, the table count or uptime. The metrics module doc names the account key.
The segment store allocated the rings of an account's operation on its first request and kept them until restart. An account that stopped sending requests, or that an operator deleted, held 111,488 bytes per operation for the life of the process. Main's prune dropped such an account's segment points after a day. The metrics prune runs every five minutes. It now drops the rings of an account's operation once the coarse ring's whole-ring window holds no bucket of theirs. It drops the account once it holds no operation. The check reuses the ring's first slot and bucket sum. The fine ring's windows lie inside the coarse ring's, so no query answer changes. The bound in the module doc, the server design doc and the deployment guide counts the accounts that sent a request in the last day. A new store test records under two accounts and prunes at 1440 and 1441 minutes. The idle account goes at 1441 minutes with its two operations. The active account keeps its ring and its data. The idle account's next request allocates its rings again.
query_segments turned an empty account filter into no filter before it read the store, and its test twin query_segments_at did not. The rule now lives in SegmentStore::query, so both readers share one copy and answer alike.
The bound test records under three accounts and five operations and asserts the bucket count of every pair. Its comment named the operations only.
The bound test asserted the number of ring pairs through a test-only accessor and then asserted the exact bucket count. Each pair holds exactly 1,742 buckets, so the bucket count fixes the pair count. The accessor and its assertion go. The random workload test described a point with a four-field struct. It is a four-tuple again, destructured as the three-tuple was before the account joined it. The single-account constant equalled the first entry of the account list and goes. Every assertion keeps its meaning.
The reference check in segments_tests.rs put the account id of its filter into the label of every assertion message. Code scanning reads an account id written to a message as cleartext logging of sensitive data, and reported two alerts on the check. The ids are test constants. The label now names the filter's index in ACCOUNTS instead, and the parameter's name is filter. No assertion changes.
demohan
left a comment
There was a problem hiding this comment.
The bucket arithmetic, the window edges and the counts hold on SQLite and PostgreSQL, and responses are unchanged against the merge-base. Four items need changes before this merges. The first blocks it: a server with many accounts and little traffic per account now holds a fixed 111,488 bytes per (account, operation) pair, and at 40 operations about 1,445 such accounts fill 6 GiB. The other three are the lock hold of the full-ring scans, the release range in the deployment guide, and a test for the collector prune. The doc items below go in the same pass. The inline comments carry the measurements.
| .entry(account_id.to_owned()) | ||
| .or_default() | ||
| .entry(operation.to_owned()) | ||
| .or_insert_with(OperationRings::new) |
There was a problem hiding this comment.
The first request of a pair allocates both rings, 111,488 bytes, and holds them for a day. Main holds about 204 bytes per request, so this uses more memory for any pair under about 546 requests a day. Release build, counting allocator, two runs: 1,000 accounts x 40 operations with one request each hold 4,464,933,520 bytes here and 10,076,896 bytes on the merge-base. On a SQLite server, 500 accounts x 17 operations with one request each grew RSS by 215 MB here and 31 MB on the merge-base. At 40 operations about 1,445 active accounts fill 6 GiB. Storing only the buckets that hold requests, ordered by slot and capped at the ring length, keeps today's ceiling and drops below main for sparse pairs. A test with many accounts and one request each would pin it.
There was a problem hiding this comment.
Reproduced on a release build with a counting allocator. 1,000 accounts x 40 operations with one request each held 4,464,933,520 bytes here, and 9,922,080 on the merge-base. 2e5e047 stores only the buckets with a request, in slot order, and caps each deque at the ring length. The same store now holds 13,605,520 bytes, 340 per pair. A pair that sends every second still tops out at 1,742 buckets. One request a day costs 340 bytes against about 248 on the merge-base, and from two requests a day on it costs less. bucket_memory_follows_the_requests_up_to_the_ring_length pins both ends, with the 1,000 x 40 row among its cases.
There was a problem hiding this comment.
Correction to my reply above. The 340 bytes per pair hold when the account sends many operations. The same harness at 5c4f613 (release build, counting allocator, 23 Nov), one request per pair:
- 1,000 accounts x 40 operations: 13,605,520 bytes, 340 per pair
- 1,000 accounts x 3 operations: 1,092,520 bytes, 364 per pair
- 1,000 accounts x 1 operation: 810,520 bytes, 810 per pair
So an account that sends one operation once a day costs about 810 bytes, against about 248 on the merge-base. A second request that day adds at most two 64-byte buckets. "From two requests a day on it costs less" was wrong for that account.
A ring's allocation also doesn't shrink. A pair that sent a request every second for 1,441 minutes, then one more a ring later, holds 2 buckets and keeps 1,742 allocated. The prune drops the pair a day after its last request. 7967ac7 puts both in the deployment guide and the design doc. 737a515 adds a row that pins the stale-bucket drop with the allocation kept: 2 buckets held in a capacity of 9.
| /// Sums every bucket whose slot is at or after `first_slot` into `acc`. | ||
| /// Slots left over from an earlier lap are older than `first_slot` for | ||
| /// every window this ring serves, so no separate staleness check is needed. | ||
| fn sum_from(&self, first_slot: u64, acc: &mut Bucket) { |
There was a problem hiding this comment.
sum_from reads the whole ring for every window, and the unfiltered query at line 254 does that for every pair under the read lock. With 1,000 accounts x 40 operations, one request each, two runs: unfiltered Last5Minutes holds the lock 67.9 to 70.6 ms (merge-base 1.95 to 2.01 ms), LastDay 297.7 to 301.0 ms (1.95 to 1.98 ms). A record waiting behind a Last5Minutes query every 50 ms waited up to 73.1 to 80.9 ms (2.5 to 4.4 ms). The console runs that query every 10 s. Reading only the window's slots, and using by_account.get when filtered, bounds it.
There was a problem hiding this comment.
Reproduced on that store. Unfiltered Last5Minutes held the read lock 76.7 to 80.5 milliseconds and LastDay 183.8 to 210.5 (merge-base 1.7 to 2.2 and 1.7 to 4.9). A record behind the query waited up to 115 milliseconds. 2e5e047 finds the window's first slot with a binary search over the held buckets and reads from there. A filtered query looks the account up with get. Now 5.2 to 12.2 and 3.7 to 5.4 milliseconds, with the longest record wait at 15.7. The host ran at a load average of 28 to 63 on 16 cores.
| /// no operation. The fine ring's windows lie inside the coarse ring's, so | ||
| /// no query answer changes; an account that has sent no request for the | ||
| /// length of the coarse ring releases its memory. | ||
| pub(super) fn prune(&mut self, now: Instant) { |
There was a problem hiding this comment.
The prune reads all 1,441 coarse buckets of every pair under the write lock. With 1,000 x 40 pairs it held the lock 289.4 to 303.4 ms, once per five minutes, against 0.08 to 0.09 ms on the merge-base. Keeping the newest recorded slot per pair makes the idle check constant per pair.
There was a problem hiding this comment.
Reproduced: 187.9 to 201.3 milliseconds under the write lock, against 0.05 on the merge-base. In 2e5e047 the newest bucket is the back of each ring's deque, so the prune compares one slot per pair. On the same store it now takes 0.27 to 1.19 milliseconds.
| segs.retain(|p| p.timestamp >= cutoff); | ||
| // Clock read under the lock, as in `record_segments`. | ||
| if let Ok(mut store) = self.segments.write() { | ||
| store.prune(Instant::now()); |
There was a problem hiding this comment.
Replacing this call with a no-op leaves all 32 metrics:: tests passing. The store test calls SegmentStore::prune directly. The guide, the design doc and the module doc state that this prune releases an idle account. A #[cfg(test)] prune_at(now) like query_segments_at, and a test that records, prunes at epoch plus 1,441 minutes and asserts the store is empty, would pin it.
There was a problem hiding this comment.
Reproduced: with the segment prune in MetricsCollector::prune made a no-op, all 32 tests passed. 2e5e047 adds prune_at(now), which prune() now calls. prune_keeps_recent_segments_and_drops_them_a_day_later records, prunes at epoch plus 1,441 minutes and asserts the store holds no bucket. The no-op fails it.
| // that crosses a bucket boundary between its clock read and its lock | ||
| // could overwrite the oldest in-window bucket before a reader with an | ||
| // earlier clock reads it. | ||
| let Ok(mut store) = self.segments.write() else { |
There was a problem hiding this comment.
Reading the clock before the lock here, or before the read lock in query_segments, leaves every test passing. The comment's property rests on the lock placement alone. A clock seam on the record path would let a test hold it.
There was a problem hiding this comment.
Reproduced for both paths. 2e5e047 moves the clock behind record_segments_with and query_segments_with, and the production paths pass Instant::now. segment_record_and_query_read_the_clock_under_the_lock passes a clock that asserts try_read and try_write on the segments lock return WouldBlock. A clock read before either lock fails it.
| number of accounts that sent a request in the last day, and not with the | ||
| request rate, the table count or uptime. | ||
|
|
||
| Releases through 0.1.13 kept one latency segment record per data-plane |
There was a problem hiding this comment.
v0.1.14, v0.1.15 and v1.0.0 all contain segments: RwLock<Vec<SegmentPoint>> in crates/core/src/metrics/collector.rs (git grep at each tag). v0.1.14 was already released when this branch was cut. An operator on 1.0.0 reads this and skips the sizing rule. Naming the last release that ships the vector, or "releases before the one that carries this change", fixes it. The PR body has the same sentence.
There was a problem hiding this comment.
git grep at v0.1.14, v0.1.15 and v1.0.0 finds the vector in each. 03bae35 makes it every release through 1.0.0 and any later release before the one that carries this change, in the guide and in the body. 11bfdbe also gives the cost per request for each release. It is about 190 bytes through 0.1.14, and about 250 from 0.1.15 on, because each record also stores the account id. The sizing rule takes the figure of the release that runs. One detail: the branch was cut on 2026-10-13, ten days before v0.1.14. The sentence came later, on 2026-11-14.
|
|
||
| ### Process Memory | ||
|
|
||
| The server's resident memory does not grow with the number of requests |
There was a problem hiding this comment.
With throttling_enabled = true, resident memory grows with requests: ThrottleManager keeps a bucket per new partition key and never removes it (crates/core/src/throttle.rs:186). On a PostgreSQL server, 60,000 PutItem with new keys grew RssAnon from 28,536 kB to 56,244 kB with throttling on and not at all with it off. The paragraph also says segment memory grows with accounts. Limiting the sentence to the metrics would make it true.
There was a problem hiding this comment.
Confirmed in the code: partitions at throttle.rs:186 only gains entries (entry(pk).or_insert_with at lines 325 and 402), and remove_table touches tables only. 03bae35 limits the sentence to the memory the metrics hold and adds one sentence on the throttle growth. 11bfdbe names the operations whose keys add a read and a write bucket: GetItem, PutItem, UpdateItem and DeleteItem, so reads grow the map too.
| flushed to the catalog, so the memory they occupy scales with the request | ||
| rate (for example six 40-byte points per GetItem, held for 60 to 120 seconds) | ||
| and not with uptime, and per-operation latency segments are summed into fixed | ||
| time buckets per account and operation, at most 111,488 bytes (109 KiB) |
There was a problem hiding this comment.
111,488 bytes is the bucket payload. Each pair also holds its operation key, OperationRings and map slots; 111,624 bytes per pair was measured. "About" would be accurate. The same applies to docs/design/06-component-server.md:361. Line 372: after the store is dropped, live bytes fall to about 1 KB but RSS stays at its high-water mark (4,359,488 kB above start for a 1,000 x 40 store), so "holds no segment memory" describes the allocator, not the process.
There was a problem hiding this comment.
Measured 111,623 bytes per pair at 1,000 x 40 and 112,137 for a single pair. After the drop, live bytes returned to the baseline while RssAnon stayed at 4,362,420 kB. With 2e5e047 the fixed figure is gone. The texts give 111,488 bytes as the bucket ceiling and about 340 bytes for a pair with one request a day. 03bae35 says the buckets return to the allocator while the resident size can stay at its high-water mark.
There was a problem hiding this comment.
Correction to my reply above. The "about 340 bytes" for a pair with one request a day holds when the account sends many operations. For an account that sends one operation it's about 810 bytes. 1,000 such accounts held 810,520 bytes on a release build with a counting allocator at 5c4f613 (23 Nov). 7967ac7 gives both figures in the guide and in the design doc. It also says that a pair keeps the largest allocation it reached until a day passes with no request for it. Then the prune frees it.
| accounts that sent a request in the last day (the 24-hour ring, 1,440 to | ||
| 1,441 minutes): the metrics prune, every five minutes, drops the buckets of | ||
| an account's operation once that window holds none of its requests, and the | ||
| account once it holds no operation. The segments are recorded only for |
There was a problem hiding this comment.
Requests refused by authorization, throttled requests and the point-in-time recovery refusal also return before the record at handler.rs:404 (lines 176, 262, 139). AccessDeniedException GetItem added no segment in a run against this branch. On line 363, the prune runs every 300 s, so an idle account is released 1,441 to about 1,446 minutes after its last request.
There was a problem hiding this comment.
Both hold. 03bae35 says the segments are recorded only for requests that reach dispatch. It names authentication, authorization, throttling and the point-in-time recovery check as the refusals that add none. On the timing: a request in minute m leaves the ring at the start of minute m + 1,441, so between 1,440 and 1,441 minutes later. The prune then runs within 300 seconds. The text says 1,440 to about 1,446 minutes.
A ring now holds only the buckets of the slots that had a request, in slot order. A record first drops the buckets outside the ring's window, then adds its own. The deque grows by doubling up to the ring length and no further. So a pair that sends a request every second still holds at most 1,742 buckets, 111,488 bytes. A pair with one request a day holds two buckets. Before this change the first request of an (account, operation) pair allocated both rings in full. On a release build with a counting allocator, 1,000 accounts x 40 operations with one request each held 4,464,933,520 bytes. Main holds 9,922,080 bytes for the same requests. With this change the same store holds 13,605,520 bytes, 340 per pair. On that store the unfiltered Last5Minutes query held the read lock between 76.7 and 80.5 milliseconds. The prune held the write lock between 187.9 and 201.3 milliseconds. Both read every slot of every ring. The query now finds the window's first slot with a binary search and reads from there (5.2 to 12.2 milliseconds). The filtered query looks the account up instead of scanning the map. The prune compares one slot per pair (0.27 to 1.19 milliseconds). The collector's prune is now `prune_at(now)` behind `prune()`. The record and query paths take their clock through `record_segments_with` and `query_segments_with`. Tests can therefore run the production prune at a chosen time and check that the clock runs inside the lock. Before this change, a no-op segment prune and a clock read before the lock both passed every test.
The base merges main at 14ade59. That brings #544 as a squash and ten other commits: #1280, #1009, #596, #1173, #398, #428, #567, #584, #588 and #864. One file conflicted: crates/engine/src/import_export.rs. #1009 moves the body of handle_import_table to import_table in the new file crates/engine/src/import_export/files.rs. The wasm32 build replaces that file with a stand-in that refuses the operation. handle_import_table keeps the enabled check and calls files::import_table. This branch changes the body that #1009 moves. When read_items finds a line that it cannot read, the import keeps the items before that line. It counts the line as one error and reads no more of the file. The merge keeps the code of main in import_export.rs, with the doc comment of this branch on handle_import_table. It makes the three changes of this branch to the body in files.rs: - The variable read holds the result of read_items: the items and the line that the reader cannot read. - The loop takes the items, then that line. At that line it logs the line number and the fault, counts one error and ends the import. - The comment over the FAILED status adds the date 2026-11-22, for the lines that the import cannot read. The body of import_table in files.rs is now the same as the body of handle_import_table at the head of this branch. Git merged docs/manuals/07-upgrade-manual.md with no conflict. #398 adds its v1.1.0 entry at the top of "Behavior Changes by Release". This branch adds its v1.1.0 entry at the end of that section.
The base merges main at 14ade59. That brings #544 as a squash and ten other commits: #1280, #1009, #596, #1173, #398, #428, #567, #584, #588 and #864. The merge has no conflict. Git merged crates/engine/src/lib.rs, the one file with changes on both sides. Main compiles three modules only off wasm32 (backup, import_export_io and private_fs), and adds the modules backup_requests and pre_dispatch. This branch adds single_write_refusal after deserialize_error.
Main is 10 commits ahead of the branch. Two files conflicted. docs/manuals/07-upgrade-manual.md: both sides add a v1.1.0 entry at the same place. Both stay, main's #398 entry first. crates/engine/src/query.rs: #544 (1ddc087) moved the Limit, enum, parameter mix, names and number checks of a Query into query_key_values::validate_query_request_body. That function reads the raw body before deserialization and before the IAM decision. This branch runs its checks in query::request_checks::check_request. The three conflict regions take this branch's side. handle_query reads the request through check_request, and the empty key condition, parameter usage and ConditionalOperator checks stay in check_request_parameters. check_request now starts with validate_query_request_body and drops its own copies of the ReturnConsumedCapacity enum check and the Limit check. check_request_parameters drops its copy of the parameter mix check. The copies of #544 merged first. The Select enum check moves out of validate_query_request_body into validate_query_select, which check_request runs after the FilterExpression and KeyConditionExpression checks, with the same shape fault rule. The measured rows settle the order. An undefined filter name (H3) and a second condition on one key attribute (B4) answer ahead of an invalid Select. An N value that is not a number (f1 of #544) and a Limit of 0 (L7, f3) answer ahead of it. The server's check before the IAM decision no longer includes Select. A principal the policy denies, with an invalid Select, now gets AccessDeniedException where main gave the Select text. That answer is not measured. Both PRs refuse a begins_with value that is not a string or a binary value. This branch's parser check stays, because the measured rows put that refusal ahead of the duplicate check (D3) and in the parse (E1, P1). handle_query now calls refuse_begins_with_on_number (#544) for a legacy KeyConditions request only, so a KeyConditionExpression is not checked twice. Two unit tests of #544 that read the Select answer from validate_query_request_body now read it from validate_query_select.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #503, #544, #567, #765 and #774, #588, #596, #690, #1144, #1173 and #1194, next to the existing entries for #398 and #526. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194 and #1375, next to the existing entries for #398, #526 and #1166. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker.
* chore(release): bump version to 1.1.0 Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker. * docs(upgrade): add the v1.1.0 entry of #1290, put #1349's in order #1290 merged after this branch was rebased. It changes the answer to a request with no Authorization header, so it gets a v1.1.0 entry. The merge of main put the #1349 entry after the #1523 entry. It moves to the place of its number, beside the new #1290 entry. --------- Co-authored-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
…1482) * fix(core): read the latency segment clock through web_time segments.rs imported std::time::Instant, and collector.rs and collector_query.rs pass web_time::Instant values to SegmentStore::new and to its record, prune and query methods. On the WebAssembly target the two types differ, so extenddb-core did not compile there. The WebAssembly workflow has failed on main since ExtendDB#398 merged (8e17259). On every other target web_time re-exports std::time, so native builds compile the same code. * test(core): read the metrics test clocks through web_time The core step of the WebAssembly workflow builds the library tests of extenddb-core for wasm32. collector_tests.rs gave record_segments_with and query_segments_with a clock that returns std::time::Instant. segments_tests.rs and segments_bound_tests.rs passed std::time::Instant values to SegmentStore. These methods take web_time::Instant, so the test build stopped with 54 mismatched types errors. The three files now import Instant from web_time, as collector.rs does. web_time re-exports std::time::Duration on every target, so the two segment test files take Duration from web_time too.
Changes since the last review
5532d07 merges main at 1d3be63. The commits after it:
bucket_memory_follows_the_requests_up_to_the_ring_length: six seconds, then one request a ring later. The pair holds 2 buckets in a capacity of 9. With the stale-bucketwhileloop inRing::recordchanged to anif, this row fails with 7 buckets held, and every other metrics test passes.Bucket::new, soadd_bucketholds the only sum over the count and the six segment fields.bench_old_push_vs_new_record. Its numbers stay under Result.bucket_countandbucket_capacityintoSegmentStore::buckets.KeyorItem. That is name order, or the request's order on a build with the MongoDB backend, so it can be the sort key. A pair's cost is the measured range under Result.The body changes too. A pair of an account that sends one operation takes about 810 bytes, and a pair keeps the largest allocation it reached. The bound per account replaces the claim that there was nothing for a setting to protect. The body also corrects what
AllTimereturned before, names the overlaps with other PRs, and gives the test results at 5c4f613.What
MetricsCollectorkept oneSegmentPointper request that reaches dispatch for 24 hours. Each point was a 136-byte struct plus three heap strings (112 bytes and two strings before 0.1.15). Every request pushed one to aVec, which only the five-minute prune trimmed. The console's Latency Breakdown and thesegmentsarray of/metricsread nothing but a per-operation count and the mean of the six latency segments over a window. The collector now sums the points at record time instead.crates/core/src/metrics/segments.rs: each account's operation owns two rings of 64-byte buckets, up to 301 one-second buckets servingLastMinuteandLast5Minutesand up to 1,441 one-minute buckets servingLastHour,LastDayandAllTime. A bucket holds a count and six sums. Slotkof a ring of widthbcovers elapsed seconds[k*b, (k+1)*b)since the collector's epoch. A ring holds only the slots that had a request, in slot order. A record first drops the buckets outside the ring, then adds its own. The ring's allocation doubles up to the ring length and stops there. The allocation does not shrink: a pair keeps the largest allocation it reached until a day passes with no request for it.accounts * operations * 111,488bytes. A pair holds all 1,742 buckets only with a request in every second of the last five minutes and every minute of the last day. A pair with one request a day holds two buckets. With its keys and map entries, that pair takes 286 to 429 bytes when its account sends 3 to 40 operations. It takes 475 bytes with 2 operations and 810 bytes with 1 (the table and the run under Result). The handler rejects anyX-Amz-Targetoutsideis_known_operationbefore it records any metric. Sooperationsis at most the 40 names in the dispatch table (37 plus the three PartiQL operations). Per account, the ceiling is 4,459,520 bytes (4.25 MiB) of buckets.accountscounts the accounts that sent a request in the last day. The handler records a segment only for a request that reaches dispatch, so these are accounts in the catalog.query_segmentsand theOperationSegmentsJSON shape do not change. The console needs no change. Per-operation counts are exact. The means are the same sums divided by the same counts as before (for integer microsecond inputs the f64 sums stay exact below 2^53). The result omits operations with no request in the window, as before.query_segmentsnow sorts the results by operation name.prune()drops the rings of an account's operation once its newest bucket left the 24-hour ring, one comparison per pair. It drops the account once the account holds no operation. So an account that stopped sending requests, or was deleted, returns its segment buckets to the allocator after a day. The process's resident size can stay at its high-water mark.What changes for a reader: a window of
Wseconds returns at least the lastWseconds and at mostWplus one bucket width.LastMinuteandLast5Minutesmay therefore include up to 1 s beyond the window, andLastHourandLastDayup to 60 s.AllTimereturns the same asLastDay. Before, it returned every point the vector held, 24 hours to 24 hours and 5 minutes of requests. The console refreshes every 10 s onLast5Minutesand shows means and a count, so this is not visible there. The upgrade manual's v1.1.0 entry lists these changes.record_segmentsno longer takes the table name. Nothing read it (the field carried adead_codeallow and a TODO). A per-table dimension would multiply the bound by the table count, which clients control.SuccessfulRequestLatencyin the persisted counter metrics still carries the table and operation dimensions.The issue asks for a granularity, retention, sampling or cap setting, an overflow counter, and a switch to turn the collection off. This PR adds none. The bound grows with the number of accounts and operations. The request rate does not change it. At the ceiling it is about 4.46 MB per account. So 1,445 accounts at the ceiling hold more than the reporter's 6 GiB limit (computed: 6 GiB / 4,459,520 bytes = 1,444.6). A cap or a switch would still protect such a deployment. #1405 tracks it. A configuration key routes through the RFC process, and this PR does not wait for it.
Why
Closes #397. On a PostgreSQL deployment of 0.1.12 at 274 requests per second, process memory reached about 4.3 GiB in 24 hours. The container limit was 6 GiB. That is the reporter's measurement, over 23.64 million requests.
The reproduction here ran on the unmodified 0.1.13 release binary. 1.2 million GetItem at 1,968 per second over 10 minutes grew anonymous memory by 193.5 bytes per request (least squares from 180 s, r² 0.998). The same build with
record_segmentsmade a no-op was flat at 0.6 bytes per request (r² 0.003). So the segment vector was the only per-request growth. 193.5 bytes times the reporter's 23.64 million requests is 4.26 GiB. PR #386 named the 24-hour segments as separate work.The vector exists at every release through 1.0.0. Until a deployment upgrades, the deployment guide now gives the growth law and a sizing rule. Through 0.1.14 the growth law is about 190 bytes per request that reaches dispatch over a trailing 24 hours, the reporter's figure. From 0.1.15 on it is about 250 bytes, because each record also stores the account id.
Overlap with other PRs
crates/server/src/handler.rs.record_segmentscall and keeps the four-argument signature (metric_table.as_deref(),LatencySegmentsby value). After this PR merges, feat(server): a request scope carries the request id to the engine's fault log lines #547 stops compiling until that call drops the table argument and passes&LatencySegments. feat(server/app): thin-bin Extensions: HTTP routers and a request observer #549 and feat(server/app): console tabs a thin binary adds #557 sit on feat(server): a request scope carries the request id to the engine's fault log lines #547.web_time::Instant, andsegments.rsusesstd::time::Instant. Whichever of the two merges second movessegments.rstoweb_time. On native targetsweb_timere-exportsstd::time.Testing done
All results are at 5c4f613 unless a line names another commit.
crates/core/src/metrics/segments_tests.rsandsegments_bound_tests.rs(new):accounts × operations × 1,742collector_tests.rsadapted to the new signature. The prune test ages points through the ring, then runs the collector'sprune_ata day later and asserts the store is empty. A new test checks that the record and query paths read the clock while holding the lock.cargo +1.97.0 test -p extenddb-core --lib metrics::run against it:prune_keeps_recent_segments_and_drops_them_a_day_laterfails.segment_record_and_query_read_the_clock_under_the_lockfails.prunea no-op,prune_drops_idle_accounts_and_keeps_active_onesandprune_keeps_recent_segments_and_drops_them_a_day_laterfail.bucket_memory_follows_the_requests_up_to_the_ring_lengthfails.bucket_memory_follows_the_requests_up_to_the_ring_lengthandboundedness_five_million_recordsamong them. With the capacity cap gone, those two fail.whilechanged to anif, the new row ofbucket_memory_follows_the_requests_up_to_the_ring_lengthfails with 7 buckets held against 2, and the other 33 metrics tests pass.tests/test_metrics.py,tests/test_console_integration.py,tests/test_console_cache_coherence.pyagainst a SQLite release build of 5c4f613, with the runtime settings ofdevtools/run-tests: 54 passed./metricscounts forLastDay,Last5MinutesandLastMinuteconsistent with the driver count and the rate. It ran on the per-operation store, before the merge with main keyed the store by account.Docs:
docs/design/06-component-server.mdsection 7.2 states the bucket widths, what each window returns, the bound per account and the memory of a pair by account shape.docs/manuals/11-deployment-guide.mdgains a Process Memory subsection for operators on releases through 1.0.0.docs/manuals/07-upgrade-manual.mdgains a v1.1.0 entry under Behavior Changes by Release, which the Process Memory subsection links to.docs/todo-index.mddrops the TODO entry for the table name field that nothing read.Result
The memory of a pair by account shape, measured at 5c4f613 on 23 Nov 2026. The harness is a release build with a counting allocator and calls the public
MetricsCollectorAPI:The same harness ran again on 24 Nov 2026, from 05:07 to 05:09 UTC, on the code of 5c4f613. It measured every count from 1 to 40 operations with 1,000 accounts. A pair cost 286 to 429 bytes with 3 to 40 operations, 475 bytes with 2 and 810 bytes with 1. The cost steps up at 4, 8, 15 and 29 operations, where the account's map of operations grows.
A temporary test at 5c4f613 recorded one request a second into one pair for 1,441 minutes: the pair held and allocated 1,742 buckets. One request a ring later left 2 buckets held and 1,742 allocated. One more request a ring after that, followed by a prune, left the same. A prune a ring and ten minutes after the last request dropped the pair.
The results below come from the per-operation store, before the merge with main keyed the store by account. The measurements ran on this host (16 cores, PostgreSQL 15 in a container, release build). The load was GetItem on an 8-item table at 1,984 per second for 20 minutes, 2.4 million requests, 0 errors:
The remaining movement is the one-minute counter flush. From 300 s on, anonymous memory oscillated between 88 and 103 MB with per-minute deltas alternating in sign. The
/metricssegmentscount for GetItem overLastDaywas 2,400,033 against 2,400,032 driver requests plus the one GetItem the table setup issues.The microbenchmarks also ran on the per-operation store, in the release profile, on a single thread, with 1 million calls and three runs each. They used the timing test that da45615 deletes. A record took 73 ns per call against 176 ns for the old push, which allocated two strings per request.
query_segments(LastDay)with 37 operations held the read lock for 39 µs (p50, 5,000 samples). The old full scan over 1 million points held the read lock for 39.3 to 39.5 ms. Every request's record waited during the scan.A record now does two hash lookups, the account and then the operation. An unfiltered query sums every account's rings, so its lock hold grows with the number of (account, operation) pairs that hold data. Measured on a release build with a counting allocator, 1,000 accounts × 40 operations with one request each. The store holds 13,605,520 bytes, 340 per pair. The same points cost 9,922,080 bytes on main, and 4,464,933,520 bytes when every pair allocated its rings in full. On that store the unfiltered
Last5Minutesquery held the read lock for 5.2 to 12.2 milliseconds. With full rings it held 76.7 to 80.5 milliseconds, and on main 1.7 to 2.2 milliseconds.LastDayheld it 3.7 to 5.4 milliseconds (183.8 to 210.5 with full rings, 1.7 to 4.9 on main). The prune held the write lock 0.27 to 1.19 milliseconds (187.9 to 201.3 with full rings, 0.05 on main). The host ran at a load average of 28 to 63 on 16 cores during these runs.On the per-operation store, under lock saturation the lock limited both shapes more than the work did. At 8 writer threads the old push ran 2.3 to 4.5 million records per second. The new record ran 2.0 to 3.1 million. The new record hashes the operation name under the lock, where the old path pushed a prebuilt point. At 16 threads both ran about 2 million. The live run above recorded 1,984 per second, three orders of magnitude below that.
Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a. Internal to the in-memory metrics collector. No wire, trait, auth, on-disk, config or CLI change.
Breaking changes
extenddb_core::metrics::MetricsCollector::record_segmentschanged from(&self, account_id: &str, operation: &str, table_name: Option<&str>, segments: LatencySegments)to(&self, account_id: &str, operation: &str, segments: &LatencySegments).query_segments(window, account_id)keeps its signature: with an account it reads that account's buckets, and without one it sums every account's. This PR updates both callers in the workspace,crates/server/src/handler.rsand the console metrics page test. crates.io listsextenddb-core1.0.0, published on 2026-11-17. Its description says the crate is internal to theextenddbbinary with no API stability promise (docs/adr/0029-crates-io-packaging.md). A reader of thesegmentsthat/metricsand/console/metrics-datareturn sees the changes that the upgrade manual's v1.1.0 entry lists. The windows are wider by up to one bucket, andAllTimeequalsLastDay. The collector sorts the operations by name and bounds the segment memory. No wire, CLI, configuration or on-disk surface changed.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.