Skip to content

lab(drf-p2): focus vs direct break-even + mis-predict/switch lease falsifier - #1763

Merged
AdaWorldAPI merged 3 commits into
mainfrom
lab/drf-p2-cost-20261024
Oct 24, 2026
Merged

AdaWorldAPI merged 3 commits into
mainfrom
lab/drf-p2-cost-20261024

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

What

Follow-up to #1762, in the same lab crate. Timings are reported, not gated.

  • examples/p2_breakeven.rs times one 4096-slot focus three ways:

    • building it (the cold gather);
    • one fold over the gathered column;
    • one direct read along the map (lookahead 16).

    Each is measured warm (repeated reps) and cold (a 512 MiB buffer, twice the 260 MiB L3, is streamed outside the timed region before each rep). The probe then reports the break-even fold count for both. Both paths are asserted to return the same answer before any number is printed.

  • New test p2_mispredicted_focus_and_64_fast_switches_leave_no_lease_and_no_corruption: a focus that was predicted but never used, plus 63 abandoned switches, are all reclaimed by evict_unused, and the two foci still held stay correct. Disabling eviction (keeping every entry) turns it red, together with l3.

Warm vs cold

A focus reads one cache line per distinct ordinal. Here that is 248–256 KiB, whatever the row count, so repeated reps are warm even with 65 536 rows. Codex caught that this PR first labelled the 65 536-row warm numbers as DRAM; they are now relabelled warm, and the cold arm was added.

Result (median ns per call, AVX-512, fold body from ndarray #376; AVX2 within ~15%)

rows map dens build warm fold warm direct warm build cold direct cold N* warm N* cold
1024 random 1.00 3 804 690 8 239 33 623 35 972 1 1
1024 random 0.25 3 821 429 5 271 34 666 28 748 1 3
65536 random 1.00 23 256 670 20 982 137 961 147 286 2 1
65536 random 0.25 23 638 430 20 611 143 249 141 826 2 2
65536 clustered 1.00 15 572 690 15 020 79 300 80 321 2 1

N* cold is the smallest N with build_cold + N·fold < direct_cold + (N−1)·direct_warm.

  • Break-even is 1–3 folds of one focus in every cell, warm or cold. The cold first touch costs both paths about the same.
  • A2 (the share of reads served from the focus) is 0.19–0.67 at cold N*. That is below the pre-registered 70–90% band only because N* is so small; A2 grows with N and reaches 0.98 at 64 full-mask folds.
  • A1 and A3 (dirty fraction, learning fraction) were not run: this probe has no writeback and no learning.

Open

  • The warm 65 536-row build is 23 µs against 3.8 µs at 1024 rows, with the same cache-line footprint. That points to TLB misses across 32 MiB of 4 KiB pages, but I have not measured it.
  • Not covered yet: focus churn under a memory budget, and dirty-row writeback (W1–W8).

Gates: 11/11 tests pass on native and on x86-64-v3; clippy --all-targets -D warnings is clean.

Board entry: .claude/board/entries/2026-10-24-drf-p2-breakeven.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg

examples/p2_breakeven.rs times, per 4096-slot focus: a cold gather
(build), one fold over the gathered column, and one direct read along
the map with lookahead 16, then reports the crossover fold count
N* = build / (direct - fold) and the A2 read-hit fraction at N*. Both
paths are asserted equal before any number is printed. Reported, not
gated.

New test p2_mispredicted_focus_and_64_fast_switches_leave_no_lease_and_no_corruption:
a predicted-but-unused focus and 63 abandoned switches are reclaimed by
evict_unused; the two held foci stay correct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0be6669f-01e4-41fc-bff2-da26098c2bee
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 24, 2026 23:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T23:32:58.869965Z 2190696 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2190696878

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/drf-focus-probe/examples/p2_breakeven.rs
@AdaWorldAPI
AdaWorldAPI merged commit e8aabd9 into main Oct 24, 2026
11 checks passed
AdaWorldAPI added a commit that referenced this pull request Oct 24, 2026
lab(drf-p2): cold-cache arm; correct the DRAM claim (stranded from #1763)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants