[PR #2610] [MERGED] feat(threads): measure thread CPU time on Windows from cycle counts #4470

Closed
opened 2026-11-03 04:17:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2610
Author: @DanielGodriNeto
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: turbo/pr-thread-cpu


📝 Commits (1)

  • 9ae37fc feat(threads): measure thread CPU time on Windows from cycle counts

📊 Changes

3 files changed (+41 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/spans.rs (+3 -2)
📝 crates/horizon-threads/Cargo.toml (+1 -1)
📝 crates/horizon-threads/src/lib.rs (+37 -0)

📄 Description

> 🤖 Opened by Daniel's AI agent (Claude Code), not by Daniel himself.

What

thread_cpu() returned None on Windows, so the benchmark spans had no per-thread CPU clock there. This implements it from thread cycle counts (QueryThreadCycleTime converted with a TSC rate measured once), +41/-3, no new dependency (one extra windows-sys feature, no Cargo.lock change). The unsafe lives in horizon-threads, so horizon-client keeps forbid(unsafe_code). x86_64 Windows only; other targets behave as before.

Parity

Diagnostics only; no gameplay or world output is touched.

Evidence

With it, a single-thread CPU microbenchmark on Windows gives stable numbers (0.9-2.5% spread in the min of 5 rounds). pr_ready.py --quick on Windows: rustfmt and clippy pass; 2 horizon-client tests (crash::stacks_start_at_the_panicking_frame, save::session_lock_is_exclusive) and some Python tests fail, all in code this PR does not touch.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2610 **Author:** [@DanielGodriNeto](https://github.com/DanielGodriNeto) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `turbo/pr-thread-cpu` --- ### 📝 Commits (1) - [`9ae37fc`](https://github.com/horizon-rust/horizon/commit/9ae37fcb5062707871c1f25d7e755f857a19feb8) feat(threads): measure thread CPU time on Windows from cycle counts ### 📊 Changes **3 files changed** (+41 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/spans.rs` (+3 -2) 📝 `crates/horizon-threads/Cargo.toml` (+1 -1) 📝 `crates/horizon-threads/src/lib.rs` (+37 -0) </details> ### 📄 Description > 🤖 Opened by Daniel's AI agent (Claude Code), not by Daniel himself. ## What `thread_cpu()` returned `None` on Windows, so the benchmark spans had no per-thread CPU clock there. This implements it from thread cycle counts (`QueryThreadCycleTime` converted with a TSC rate measured once), +41/-3, no new dependency (one extra `windows-sys` feature, no `Cargo.lock` change). The `unsafe` lives in `horizon-threads`, so `horizon-client` keeps `forbid(unsafe_code)`. x86_64 Windows only; other targets behave as before. ## Parity Diagnostics only; no gameplay or world output is touched. ## Evidence With it, a single-thread CPU microbenchmark on Windows gives stable numbers (0.9-2.5% spread in the min of 5 rounds). `pr_ready.py --quick` on Windows: rustfmt and clippy pass; 2 horizon-client tests (`crash::stacks_start_at_the_panicking_frame`, `save::session_lock_is_exclusive`) and some Python tests fail, all in code this PR does not touch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:17:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
horizon-rust/horizon#4470
No description provided.