Repository navigation
Conversation
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks for the measurements and the ADR. I read the change against main at 9c3fbfb. Default builds do not change, and the allocator applies only to the bin crate. The CI runs for this PR wait for a maintainer to approve them, so no check has run yet.
A new `mimalloc` feature on the bin crate makes mimalloc the global allocator in place of the system allocator. Default builds do not change. The clippy workflow builds the feature. Measured on the PostgreSQL build of main at 9c3fbfb on glibc, under conditional PutItem and PartiQL INSERT load with 32 requests in flight: with mimalloc, server CPU for each request fell by about 12% and throughput rose by about 2% to 4%. Peak resident memory was higher. ADR-0030 records the measurements and why the feature is off by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: michael parsons <michael@twisp.com>
82079fe to
83320bb
Compare
LeeroyHannigan
left a comment
There was a problem hiding this comment.
I read 83320bb. The clippy run at clippy.yml:39 now builds extenddb/mimalloc, and the comment in main.rs points at ADR-0030. The ADR now measures main at 9c3fbfb. It reports about 12% less server CPU per request and a throughput change close to the noise. It also reports higher peak resident memory with mimalloc. Clippy, with the new feature run, and Licenses pass at this head.
The ADR index conflicted: main added a License section after the table, and this branch added the ADR-0030 row. The row goes at the end of the table, before the License section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: michael parsons <michael@twisp.com>
ExtendDB#964 gave every document under docs/ the same License section, with a second paragraph that says ExtendDB is maintained by AWS and is not Amazon DynamoDB. ADR-0030 had the first paragraph only. It now has the same section as ADR-0029. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: michael parsons <michael@twisp.com>
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks for the changes. You fixed both items from my 11 Nov review. The clippy job now builds the feature (clippy.yml:39), and the comment in main.rs points at the ADR instead of stating the figure. The default build doesn't link mimalloc, with no mi_ symbols in the binary. The feature build passes the bin crate's tests against PostgreSQL 16, and the merge with main is clean.
One change before it merges:
- I couldn't reproduce ADR-0030's figures from what it states. It names no load generator, command line, PostgreSQL settings or worker count, and no method for "server CPU per request" or "peak resident memory". "After about 600,000 inserts" also doesn't fit a 10 s window at about 15,000 ops/s. I wrote my own client (32 processes, one SigV4 HTTPS connection each, PostgreSQL 16 on loopback). Other builds shared the host (load average 14 to 36), so I only compared ratios. The CPU result held: server CPU per request fell 13% to 16% for INSERT and 1.5% to 11% for PutItem. The memory result didn't hold at a longer run. Servers with 62,000 to 82,000 inserts ended at 121.0 to 126.5 MB with mimalloc and 92.5 to 100.5 MB with glibc. In a run of about 500,000 inserts per server, mimalloc ended at 221.5 MB and glibc at 231.2 MB. Please add the script and the commands (or name the tool), and say how you read CPU and peak memory. Then reword the memory sentence so it doesn't claim a direction at 600,000 inserts that nobody can check. Keeping only the relative figures, with the host they came from, would also work.
These were already there at my last review, so they aren't conditions for this PR:
- The ADR says the Linux system allocator is glibc malloc, but the npm packages' Linux binaries are musl builds (
npm-build-matrix.yml:43and:46). docs/adr/README.mdsays an ADR is Accepted on merge, so ADR-0030 and its index row can say Accepted.MALLOC_ARENA_MAX, which the admin and deployment guides recommend for backups, doesn't bound Rust allocations in a mimalloc build. A sentence in the ADR's Consequences would cover it.- Cargo.lock moves winapi-util's windows-sys from 0.48.0 to 0.61.2, which the feature doesn't need.
- "Applies to the whole process": C libraries such as aws-lc keep the system malloc, because the crate's
overridefeature is off.
No conflicts. Cargo.lock is main's file with the mimalloc and libmimalloc-sys packages added and nothing else. The earlier lock file of this branch also moved the windows-sys version of winapi-util, which the feature does not need; that change is gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012kcReu8W93hWBjX8JAwW8P Signed-off-by: michael parsons <michael@twisp.com>
The review could not reproduce the figures of ADR-0030 from its text. The ADR now has a Method section: the builds, the host, the PostgreSQL and server settings, the load generator and its commands, and how server CPU per request, peak resident memory and the profile were read. The load generator and the run script are in the description of the pull request. The memory sentence said "after about 600,000 inserts". VmHWM was read one time at the end of a measurement of eight steps, after 630,000 to 862,000 inserts, and it is in MiB now. The review measured lower memory with mimalloc in a longer run, so the ADR gives both sets of figures and makes no claim about a direction. Other points from the review: - The Linux binaries of the npm packages are musl builds, so "the system allocator" is not glibc malloc for them. The ADR measured glibc only. - The global allocator serves Rust allocations. C libraries such as AWS-LC keep the system malloc, because the override feature is off. - MALLOC_ARENA_MAX does not bound Rust allocations in a build with the feature. - The status is Accepted, as docs/adr/README.md says for a merged ADR. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012kcReu8W93hWBjX8JAwW8P Signed-off-by: michael parsons <michael@twisp.com>
|
Thanks for the review, and for the second set of measurements. The changes are at 382858d. 1. ADR-0030 figures. The ADR has a Method section now: the builds, the host, the PostgreSQL and server settings, the worker count, the load generator and its commands, and how server CPU per request, peak memory and the profile were read. The run script and the source of the load generator are in the PR description.
The items that were not conditions:
The branch has |
ADR-0031 records the stored form: the escape of the item documents, the refusal of U+0000 in a PostgreSQL key, the MongoDB mark, and migration 13. 0031 is the first number that no open PR claims: #529 and #536 add 0028, and #954 adds 0030. - differences-from-dynamodb.md lists the refusal of U+0000 in a key on PostgreSQL. - The upgrade manual's entry is now a v1.1.0 entry. It says what an operator sees when the data body fails after the catalog body committed, and describes the MongoDB mark. The Current Status paragraph about 1.0.0 and migrations 1 to 12 is as main has it. - 04-component-storage.md and the escape module's comment no longer say that the key columns hold escaped text. The escape's byte order and prefix tests go with that claim. map_json checks a key with needs_escape.
LeeroyHannigan
left a comment
There was a problem hiding this comment.
I reran the Method of ADR-0030 at this head (382858d) with the script and the Go load generator from the description. I changed only container names, ports and how the server's PID is found. My host has 16 CPUs, and other builds kept its one-minute load at 17 to 34, so I compared ratios.
- You fixed the item of my last review. The Method names the builds, the PostgreSQL settings, the pool sizes, the worker count, and the generator with its commands. It also says how to read CPU per request and peak memory. The memory sentence no longer claims a direction.
- At 32 in flight, server CPU per request for INSERT fell 12.0% with mimalloc (408.5 to 359.6 µs), as the ADR says.
- For PutItem it fell 6.4% (343.2 to 321.2 µs), and 4.0% to 10.0% per round. That is about half of "about 12%". The sentence and the table are as they were at my last review, where I said the CPU result held, so this isn't a condition. If you want to give the spread, you could add the figures from a second host. Over my two reviews, a 16-core host under other load measured 1.5% to 11% for PutItem and 10% to 16% for INSERT.
- Peak memory was higher with mimalloc in two pairs and lower in one, which fits the ADR's "no claim".
- The default release binary has no
mi_symbols. The feature binary has 63T mi_symbols,mi_freeandmi_malloc_alignedamong them, and it still imports the Cmalloc, as the new bullet says. - The other changed sentences match the code and Cargo.lock. They cover the glibc and musl builds, the Accepted status, the
overridefeature, theMALLOC_ARENA_MAXbullet and the two new crates. Both crates are MIT, and the license notices are current for PostgreSQL, MongoDB and Cassandra.
Before it merges, it needs another merge of main. It conflicts in docs/adr/README.md, where main added the row for ADR-0031 (#1449). With both rows kept, 0030 before 0031, the merge builds in release with and without the feature. The bin crate's tests then pass with the feature against PostgreSQL 16.
CI hasn't run at this head yet.
| turns the feature on by default. That decision needs measurements from more | ||
| workloads (read-heavy, Scan, the other backends), of resident memory in long | ||
| runs, and of a musl build. | ||
| - `MALLOC_ARENA_MAX` is a setting of glibc malloc. The backup and restore |
There was a problem hiding this comment.
Nit: the admin guide also describes MALLOC_ARENA_MAX. Its max_concurrent_jobs row (docs/manuals/05-admin-guide.md:160) tells operators to set MALLOC_ARENA_MAX=1, and it sizes hosts under that setting. You could name it here beside the backup and restore manual and the deployment guide.
navareamol
left a comment
There was a problem hiding this comment.
I rebuilt this head in release mode with and without the mimalloc feature and ran a conditional insert load against PostgreSQL 16, three runs of each build in turns, 32 requests in flight. I used my own client, so the request rate is not comparable to yours, but server CPU per request is. PutItem went from 549, 551 and 553 microseconds to 518, 510 and 513 (6 to 7 percent lower). PartiQL INSERT went from 605, 606 and 606 to 550, 542 and 544 (9 to 11 percent lower). The ADR and the description say about 12 percent for both. Could you change the sentence to a range, for example 6 to 12 percent depending on the operation, and say that it is for this host? Peak resident memory was higher with mimalloc in all three of my pairs (about 126 to 132 MB against 98 to 101 MB), which fits the ADR's "no claim", but the Consequences section could name the short run direction too.
Other checks passed here. The default release binary has no mimalloc symbols and the feature binary has 63. Cargo.lock adds only the two crates. The quickstart command works from the repository root. The command that the PR adds to clippy.yml passes with warnings as errors on 1.97.0, and I ran it myself because CI has not run at this head.
I will approve once the branch is merged with main (docs/adr/README.md conflicts) and the 12 percent sentence matches the range that was measured.
What
Adds an opt-in
mimallocfeature to the bin crate. With it,mimalloc::MiMallocis the process's#[global_allocator]in place of the system allocator.crates/bin: optionalmimallocdependency, amimalloc = ["dep:mimalloc"]feature, and a#[cfg(feature = "mimalloc")] #[global_allocator]inmain.rs.Cargo.toml:mimalloc = { version = "0.1", default-features = false }in[workspace.dependencies]. The crate'ssecurefeature stays off.docs/adr/0030-optional-mimalloc-allocator.md: the measurements, their method, and why the feature is off by default.docs/manuals/04-quickstart-setup-guide.md: the build command..github/workflows/clippy.yml:extenddb/mimallocjoins thetest-hooksclippy run, so CI builds the feature.Default builds do not change.
Why
Closes #953
Measured on the PostgreSQL build of
mainat 9c3fbfb plus this feature only, on glibc 2.36. The load is conditional inserts with unique keys, sent asPutItemwithattribute_not_existsand as PartiQLINSERT, with 32 requests in flight:PutItemPutItemINSERTINSERT* The host also ran other work, which disturbed this step.
perfprofile under thePutItemload,libc.so.6took 16% of the server's samples with glibc malloc and 5% with mimalloc.VmHWMat the end of my measurements was 302 to 351 MiB with glibc malloc and 389 to 418 MiB with mimalloc, after 630,000 to 862,000 inserts. The review measured lower memory with mimalloc after about 500,000 inserts with another client. The ADR gives both sets of figures.An earlier revision of this description gave figures from a fork build that carried two unrelated write-path changes (28% of CPU in
libc.so.6, 8.6% more throughput, 23% less CPU). The figures above replace them.How the figures were measured
The Method section of the ADR has the full text. In short:
cargo build --release --locked -p extenddb, with and without--features mimalloc, in therust:1.97-bookwormimage withRUSTFLAGS=-Cforce-frame-pointers=yes.run-one.sh <glibc|mimalloc> <label>(below): a newpostgres:16-alpinecontainer, a new deployment and server process (pools of 20, the default 24 tokio workers), then the load generator forPutItemand forINSERT, each at 1, 8, 32 and 128 requests in flight for 10 seconds. Three measurements of each build, in turns:for i in 1 2 3; do ./run-one.sh glibc glibc-$i; ./run-one.sh mimalloc mimalloc-$i; done.utime + stimeof the server process from/proc/<pid>/stat, read every 100 ms; the ticks of a 10-second step divided by the requests that the step completed.VmHWMfrom/proc/<pid>/status, read one time after the last step. An earlier revision said "after about 600,000 inserts" and gave kB/1000 as MB. The counts are 630,000 to 862,000 inserts for each measurement, and the figures above are MiB.LEVELS=32 DUR=40s ./run-one.sh <build> perf-<build>, withperf record -F 999 -g -p <pid> -- sleep 25started 6 seconds into thePutItemstep, thenperf report --no-children --sort dso.The script and the load generator are the ones I ran, with the directory and the names of the test access key changed, and with two options of the load generator that this benchmark does not use removed.
run-one.sh: one measurementload/main.go: the load generator (go build -o out/extenddb-load ./load)load/go.mod:Testing done
The branch now has
mainat 44cd436 merged in (6f23c8f), with no conflicts.Cargo.lockis the file ofmainwith themimallocandlibmimalloc-syspackages added and nothing else: thewindows-syschange ofwinapi-utilthat an earlier revision carried is gone.On this host, at 382858d, with toolchain 1.97.0 as in
clippy.yml:clippywith the new feature,run-testson stable and 1.88.0, and the PostgreSQL, SQLite, MongoDB and Cassandra integration jobs. CI has not run at 382858d yet.cargo test --workspacelocally. The library crates and their test binaries do not see the feature, because only the bin crate sets the allocator. CI runs the workspace tests.mainat 9c3fbfb. The changes since then are a code comment, the ADR, the clippy workflow line and the merges ofmain, so I did not measure again.Checklist
cargo test --workspace): in CI at 83320bb; not run locally (see above)cargo fmt --check)cargo clippy -- -W clippy::pedantic): no new warnings incrates/bin; the two there, missing backticks on doc lines 4 and 10 ofmain.rs, are onmaintoo. Theclippy.ymlgate with-D warningspassesclippy.ymlrun builds the featureStoragetrait, 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: ADR-0030. The number 0030 is the next unused one after the index's 0029. Renumber it if 0028 or another number is reserved.
Breaking changes
None. Default builds do not change.
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.
🤖 Generated with Claude Code
https://claude.ai/code/session_012kcReu8W93hWBjX8JAwW8P