Skip to content

quest(m3): delete Vec::drain from std's MIR - #636

Merged
kixelated merged 4 commits into
mainfrom
quest/m3/ts-unsafe/vec-drain-mir
Nov 7, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m3/ts-unsafe/vec-drain-mir

Conversation

@kixelated

@kixelated kixelated commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Deletes Vec::drain from std's MIR and its link in the ts-unsafe epic. The runtime's port (rs.vecDrain, rs.byteVecDrain) stays.

Why

A spike (branch spike/vec-drain-mir, now deleted) translated alloc::vec::drain and Vec::drain as the crate's own code:

  • std structs and writing std functions. std's Drain is a std struct taking &mut Vec, with unsafe bodies; translating it from MIR needs std structs and writing std functions (&mut, unsafe) lowered from MIR, which the translator refuses.

  • Elements JS keeps as objects are refused. as_ptr().add(start), offset_from, and slice::from_raw_parts over such elements need pointer arithmetic into an array of objects, which the epic's 2026-11-01 decision refuses. moq's one Vec::drain (priority.rs:216) is a Vec<Waker>.

  • Even for u8/u32 elements it is 3 to 12x slower. CPU time (process.cpuUsage) per slices::drains call in Node 24, 1024-byte input draining 254 elements of each vector, a range over two interleaved runs on a loaded host:

    kind port (us) std's MIR (us)
    0: iterate 70-107 629-703
    2: collect 54-103 496-600
    4: last, count 51-112 614-696
    6: count 59-115 278-297

    About 40% of the time is in Proxy reads and most of the rest in the room's Map: set_len(start) moves the range and tail into the Vec's room, std's code reads them back through a Proxy view, and ptr::copy moves the tail back one element at a time.

The port follows std line for line, and slices::drains tests it against native (items, drops, panics, forgotten drains) on every just ci.

The draft's correction that moq's client.rs:821 drain is a VecDeque, not a Vec, lived only in the deleted quest; nothing else in the tree cites that line, so it goes with it.

Decisions

  • ✅ Delete this quest and BinaryHeap from std's MIR, keeping the runtime's ports (maintainer, 2026-11-07).
  • Rejected: an epic with prerequisites (std structs and writing std functions from MIR; pointers into arrays of objects as rs.AtIndex, which would reopen the 2026-11-01 decision).
  • Rejected: MIR only for elements JS copies, which leaves two implementations and the port still tracking std by hand.

Impact

None: quest files only. No public API or wire change.

Validation

  • quest check --fix: 50 documents ok.
  • just check: passed (lint, quest).

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, high effort

Review

Skipped: a quest-only deletion needs no review round.

(Written by Claude Opus 5.5 with high effort)

🤖 Generated with Claude Code

@pullfrog

pullfrog Bot commented Nov 7, 2026

Copy link
Copy Markdown

Pullfrog  | Review this ➔

kixelated and others added 3 commits November 7, 2026 04:40
…it to the maintainer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
std's Drain needs std structs and writing std functions translated from
MIR, which the translator refuses, and pointer arithmetic into arrays of
objects, which the epic's 2026-11-01 decision refuses. Even for elements
JS copies it ran 3 to 12x slower than the port, which follows std line
for line and is tested against native on every `just ci`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Vec::drain from std's MIR quest(m3): delete Vec::drain from std's MIR Nov 7, 2026
@kixelated
kixelated marked this pull request as ready for review November 7, 2026 14:39
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

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: 1dc15c52-e298-4e79-970d-30fed305acf4
Commits

Reviewing files that changed from the base of the PR and between fd62edf and 291ea6f.

Files selected for processing: 2

  • quest/m3/ts-unsafe/README.md
  • quest/m3/ts-unsafe/vec-drain-mir.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@kixelated
kixelated added this pull request to the merge queue Nov 7, 2026

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit 291ea6f against base fd62edf.

No actionable findings. The two-file change removes the Vec::drain MIR quest and its Required-list entry together, without changing runtime ports or tests. Retaining the existing port is consistent with the epic's documented restriction on arithmetic into arrays of object-valued elements. The separate BinaryHeap quest remains listed for its own PR.

Verification limits: GitHub-only static review of the deletion and surrounding epic. I did not run quest validation or reproduce the deleted spike, benchmark measurements, or native differential tests; the reported performance and passing validation remain author-provided evidence. This is a COMMENT, not an approval.

(Written by review (OpenAI))

Merged via the queue into main with commit 6231cec Nov 7, 2026
7 checks passed
@kixelated
kixelated deleted the quest/m3/ts-unsafe/vec-drain-mir branch November 7, 2026 15:21
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.

1 participant