Skip to content

test(ios): count only dead names when checking thread port release - #42

Merged
heoblitz merged 1 commit into
toss:mainfrom
AI-Dico:fix/process-metrics-dead-names
Nov 16, 2026
Merged

heoblitz merged 1 commit into
toss:mainfrom
AI-Dico:fix/process-metrics-dead-names

Conversation

@AI-Dico

@AI-Dico AI-Dico commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

releasesThreadPorts in NectoProcessMetricsTests flakes in full swift test runs. It counts every Mach port name in the test process, and other suites running in parallel in the same process create live ports of their own, so the growth crosses the < 100 threshold even though the sampler gives every thread port back. The test passes on its own every time.

A thread port that is kept turns into a dead name when its thread ends, which is exactly what the test guards against. This change counts dead names only (MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME), computed by hand because Swift does not import the macro). The threshold and loop are unchanged.

Test Plan

On macOS 26.4, Xcode 26.6 (Swift 6.3.3), Apple Silicon:

full swift test, 5 runs
before 4 of 5 failed: (portNameCount() - before → 104 / 111 / 101 / 102) < 100
after 5 of 5 passed, 198 tests in 14 suites
after, with mach_port_deallocate removed from cpuAndThreadCount() fails: (deadNameCount() - before → 299) < 100
  • swift test --filter releasesThreadPorts passes before and after.
  • Only a test file changes; no app, SDK or panel code.
  • The USB path is not involved.

🤖 Generated with Claude Code

https://claude.ai/code/session_013tPsMTtKYpkDKdppcTMEgM

releasesThreadPorts counted every port name in the test process. Other
suites run in parallel in the same process and create live ports of their
own, so the growth crossed the threshold in 4 of 5 full `swift test` runs
(101 to 111 against < 100) while passing on its own every time.

A thread port that is not given back becomes a dead name once its thread
ends, so count dead names only. Removing mach_port_deallocate from the
sampler still fails the test (+299 dead names), and full runs now pass
5 of 5.

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

@heoblitz heoblitz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for your contribution.

@heoblitz
heoblitz merged commit 65f9a04 into toss:main Nov 16, 2026
7 checks passed
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