<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ydb/library/cpp/yt/system/cpu_id.cpp, branch CLI_2.32.0</title>
<subtitle>Mirror of YDB github repos</subtitle>
<id>https://code.mastervirt.ru/ydb/atom?h=CLI_2.32.0</id>
<link rel='self' href='https://code.mastervirt.ru/ydb/atom?h=CLI_2.32.0'/>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/'/>
<updated>2026-06-15T08:32:51Z</updated>
<entry>
<title>Make library/cpp/yt/rseq a Linux-only dependency of library/cpp/yt/system</title>
<updated>2026-06-15T08:32:51Z</updated>
<author>
<name>babenko</name>
<email>babenko@yandex-team.com</email>
</author>
<published>2026-06-15T08:13:32Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=12be02b42fc24cf7bd990d56da8cf8908a35db2d'/>
<id>urn:sha1:12be02b42fc24cf7bd990d56da8cf8908a35db2d</id>
<content type='text'>
Make library/cpp/yt/rseq a Linux-only dependency of library/cpp/yt/system
commit_hash:7d6f5e738658447529440425b55b2891f6664d81
</content>
</entry>
<entry>
<title>Add library/cpp/yt/rseq: NYT::GetCurrentCpuId() via Linux rseq</title>
<updated>2026-06-13T22:35:19Z</updated>
<author>
<name>babenko</name>
<email>babenko@yandex-team.com</email>
</author>
<published>2026-06-13T22:15:56Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=450b2fac082943e2029b3390c99501c365795d64'/>
<id>urn:sha1:450b2fac082943e2029b3390c99501c365795d64</id>
<content type='text'>
Self-contained current-CPU-id reader backed by Linux **rseq** (restartable
sequences), with **no third-party dependency** (no librseq):

* The rseq ABI is hand-defined; the calling thread is registered lazily via the
  rseq syscall.
* Fast path is a single inlined, **branch-free** thread-local read. The offset
  always points at a readable `cpu_id` -- the glibc-owned area when glibc registers
  rseq (&gt;= 2.35, via the weak `__rseq_offset`/`__rseq_size`), otherwise our own
  area -- so an unregistered thread reads `-1` and routes to the slow path.
* Falls back to `sched_getcpu()` (Linux) or `0` (darwin/windows). Works on glibc
  **and musl** alike (librseq does not build on musl).

Fiber-TLS contract: the inlined read must be reached only via a non-inlinable,
fiber-switch-free frame (a virtual call or `YT_PREVENT_TLS_CACHING`).

#### Benchmark -- cost of one cpu-id read

| source | time / call |
|---|---|
| `GetCurrentCpuId()` (rseq) | **0.34 ns** |
| `sched_getcpu()` (vDSO) | 3.5 ns |
| `rdtscp` (what `TTscp::Get()` does) | 23 ns |

This is an alternative to the librseq-based review/13886037 -- same speed, but no
contrib dependency and it also covers musl. The unit test pins to each allowed CPU
and asserts the reported id matches.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
commit_hash:09d282c2f48755836b1cd68cedbffc3c6a662eed
</content>
</entry>
</feed>
