Skip to content

Repeated 32 KiB allocations in the polling driver on macOS #1107

Open

Description

@jiaojing

While investigating allocation overhead on macOS, repeated temporary event-buffer allocations were found in the polling driver.

Environment:

  • macOS 26.3, Apple Silicon
  • Rust 1.98.1
  • Initially observed with compio-driver 0.12.5 and polling 3.11.0
  • Also reproduced on upstream commit 3d99337 (compio-driver 0.13.0-beta.1)

The reproducer creates one Proactor and one waker, warms up for eight iterations, then measures 1,000 iterations of:

waker.wake_by_ref(); driver.poll(None).unwrap();

The measured result is 1,000 allocation requests totaling 32,768,000 bytes. No sockets or application traffic are involved.

The allocation appears to originate from Driver::with_events

let mut events = std::mem::take(&mut self.events);

mem::take creates a default replacement. In polling 3.11.0, Events::default() allocates capacity for 1,024 events, requesting 32 KiB on this kqueue backend. That replacement is dropped when the original container is restored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

driver: pollingAbout the polling driverpackage: driverRelated to compio-driverperformancePerformance related (regression/optimization)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions