optimizations #29

Merged
pxc1984 merged 25 commits from EminovTagir/posvyat-challenge:wanna-sleep-balbesik into master 2026-11-07 22:24:59 +00:00
Contributor

optimizations

optimizations
submissions: wanna-sleep-balbesik — C, epoll, in-memory store, group commit
All checks were successful
challenge / find (pull_request_target) Successful in 3s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 31m58s
2b6d17c2cb
One process, one thread: own HTTP/1.1 over edge-triggered epoll, the whole
database in memory (seed tables and file bodies in memfd), writes as idempotent
group commits over 12 libpq pipeline lanes keyed by (assignment, student).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhqEDnpbZCZWQ2h1Xo
wanna-sleep-balbesik: tables in shared memfd, no per-connection buffers at rest
All checks were successful
challenge / find (pull_request_target) Successful in 6s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 29m12s
4ac3520e42
Big tables, pair arrays and seed file offsets live in shared memfd mappings
(shmem, not anonymous memory, no copy-on-write on grades and submits); idle
connections drop their output buffers and unsent pre-rendered bodies are kept
by reference. Peak anonymous memory in a 5-minute hold: 25 MB instead of 50+.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
wanna-sleep-balbesik: re-run the benchmark
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 19m16s
d7ed0dfdf1
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
EminovTagir force-pushed wanna-sleep-balbesik from d7ed0dfdf1
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 19m16s
to a2fd769d84
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 49m28s
2026-11-02 18:24:57 +00:00
Compare
wanna-sleep-balbesik: re-run the benchmark
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 49m34s
72b61a5ee5
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
wanna-sleep-balbesik: uploaded file bytes leave memory after their commit
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 49m32s
7ec70dbd73
Downloads of committed uploads are served from the database like seed files;
the bytes stay in the pending write op only until it commits. Before, every
upload was appended to the memfd data file for the life of the process, which
pushed the cgroup past 1 GB after ~45 minutes of load and got the process killed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
Owner

Замечание по правилам: в PR закоммичен бинарник submissions/wanna-sleep-balbesik/server-old (~1 МБ). Готовые бинарники не коммитятся, их собирает build.sh. Нужно убрать файл из PR.

Замечание по правилам: в PR закоммичен бинарник `submissions/wanna-sleep-balbesik/server-old` (~1 МБ). Готовые бинарники не коммитятся, их собирает `build.sh`. Нужно убрать файл из PR.
pxc1984 force-pushed wanna-sleep-balbesik from 7ec70dbd73
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 49m32s
to f70c179e77
Some checks failed
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Failing after 3s
2026-11-03 08:04:10 +00:00
Compare
pxc1984 force-pushed wanna-sleep-balbesik from f70c179e77
Some checks failed
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Failing after 3s
to 11840c5696
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 20m21s
2026-11-03 08:48:37 +00:00
Compare
pxc1984 force-pushed wanna-sleep-balbesik from 11840c5696
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 20m21s
to 1c0daa2159
Some checks failed
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Has been cancelled
2026-11-03 11:05:30 +00:00
Compare
pxc1984 force-pushed wanna-sleep-balbesik from 1c0daa2159
Some checks failed
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Has been cancelled
to 11d97560a6
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 23m5s
2026-11-03 11:13:34 +00:00
Compare
pxc1984 force-pushed wanna-sleep-balbesik from 11d97560a6
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 23m5s
to 6120db8032
Some checks failed
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Has been cancelled
2026-11-03 11:46:09 +00:00
Compare
pxc1984 force-pushed wanna-sleep-balbesik from 6120db8032
Some checks failed
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Has been cancelled
to 8ebff74829
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 20m33s
2026-11-03 12:21:27 +00:00
Compare
EminovTagir force-pushed wanna-sleep-balbesik from 8ebff74829
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/wanna-sleep-balbesik) (pull_request_target) Successful in 20m33s
to a9eeece458
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m46s
2026-11-03 13:54:21 +00:00
Compare
c-epoll-balbesik: cheap updates for existing submissions
Some checks failed
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Has been cancelled
1f6f0006c1
Submits and grades of rows already in the database become column-specific
multi-row UPDATEs (grades touch no indexed column); only new submissions go
through the full-state upsert. Less work per write on the shared Postgres.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
c-epoll-balbesik: remove stray local binaries from the submission folder
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m11s
13c57442f0
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
c-epoll-balbesik: probed course-set cache, Fenwick-tree paging for staff listings
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m16s
9fc7b5876d
The two student course sets collided in the direct-mapped response cache and
re-rendered the 20 KB assignments list on every request; the cache is now a
256-entry table with linear probing. Staff submission listings jump to their
offset through a per-assignment Fenwick tree over the pairs instead of scanning.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
c-epoll-balbesik: compact rows (32/16/16 B), 16-bit pair keys, bitset pair build, small string tables
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 25m17s
3a6c7cdd78
- Sub 48->32 B, SFile 24->16 B, Msg 24->16 B: 40-bit ms timestamps, 16-bit user/assignment ids,
  16-bit name/feedback ids and 8-bit content-type ids into small string tables; overflow beyond
  65534/254 distinct values falls back to the big table via a per-row map (sentinel id), so
  behaviour never changes
- string tables keyed by a word-wise 64-bit hash with open addressing
- pairs: separate dense u16 key array for the binary search; built at load from a per-assignment
  65536-bit set (sorted + unique by walking set bits, exact-size, no inserts/Fenwick rebuilds);
  linking 548 ms -> 57 ms; later growth through size-class free lists in shmem
- reader jobs resolve file name/type from the row at response time
- idle cgroup memory ~119 MB -> ~103 MB

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
c-epoll-balbesik: re-run benchmark (run 388 overlapped another submission on the shared DB)
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m4s
b0570d05a2
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
c-epoll-balbesik: FSST-compressed chat bodies, prepared statements, latency histograms, exact pair allocator
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m5s
ec7e846730
- chat message bodies posted at runtime go to a raw arena (varint length + bytes) compressed with
  a static symbol table (FSST, 255 symbols of 1-8 bytes) trained in a background thread on the
  first 2048 bodies and re-trained on 65536, published atomically; ~5x on chat-like text, so a new
  message costs ~25 B instead of ~85 B; seed bodies stay interned; repeated runtime bodies dedup
  through a small direct-mapped cache
- all writer/reader statements prepared once per link (PgBouncer >= 1.21 transaction mode tracks
  them); if the prepare batch fails or a link later reports 26000, that link sends SQL per batch.
  pg_stat_statements locally: Postgres CPU for our statements -33%
- per-route latency histograms (8 log-linear buckets per octave) in the stats output
- shmem allocator cuts exact-size blocks, free lists by floor class; pair arrays grow 1.5x
- optional GENERIC=1 (SET LOCAL plan_cache_mode per batch) measured and left off: costs a round trip

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QfSKVhD8JuZ9kB4AwvEqD9
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m38s
bc62b9478c
EminovTagir changed title from wanna-sleep-balbesik: C, epoll, in-memory store, group commit to optimizations 2026-11-03 19:08:18 +00:00
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m36s
ac80d3bf83
pxc1984 force-pushed wanna-sleep-balbesik from ac80d3bf83
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m36s
to da786a0be0
All checks were successful
challenge / find (pull_request_target) Successful in 1s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 20m20s
2026-11-04 13:31:10 +00:00
Compare
optimizations
Some checks failed
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Has been cancelled
c95301711f
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m32s
07d8cb6d8f
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 24m41s
4a2f0da83f
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 26m11s
2aef225a71
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m28s
ef4b77cda1
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 20m21s
6077771b39
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m35s
a687258085
optimizations
Some checks failed
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Has been cancelled
ab2d83cb0b
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m6s
c2b21ae6bf
optimizations
Some checks failed
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Has been cancelled
a54d07ee0a
optimizations
All checks were successful
challenge / find (pull_request_target) Successful in 2s
challenge / run (submissions/c-epoll-balbesik) (pull_request_target) Successful in 19m24s
b72b3b4aa8
pxc1984 merged commit 0b61ab09d6 into master 2026-11-07 22:24:59 +00:00
pxc1984 referenced this pull request from a commit 2026-11-07 22:25:01 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cu3rd/posvyat-challenge!29
No description provided.