<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ydb/library/cpp/yt/threading/ya.make, branch meta-1.0.3-dev2</title>
<subtitle>Mirror of YDB github repos</subtitle>
<id>https://code.mastervirt.ru/ydb/atom?h=meta-1.0.3-dev2</id>
<link rel='self' href='https://code.mastervirt.ru/ydb/atom?h=meta-1.0.3-dev2'/>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/'/>
<updated>2025-04-17T11:47:23Z</updated>
<entry>
<title>YT-24537: Prioritize writers in TReaderWriterSpinLock, rename old version to TWriterStarvingRWLock</title>
<updated>2025-04-17T11:47:23Z</updated>
<author>
<name>pavook</name>
<email>pavook@yandex-team.com</email>
</author>
<published>2025-04-17T11:21:12Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=6b567e38e0404cb1f94132fb48f6cb4b8ab1c800'/>
<id>urn:sha1:6b567e38e0404cb1f94132fb48f6cb4b8ab1c800</id>
<content type='text'>
Previously, it was possible that `TReaderWriterSpinLock` wouldn't let the writer through if there's a steady flow of readers.

This change addresses that by:
1. Prioritizing writers inside the spinlock by adding an additional `WriterReady` flag that writers set on arrival. This flag doesn't allow any readers to come through.
2. Adding the proper tests to verify this functionality, as well as spinlock's behaviour under forks.
3. Clarifying the documentation about spinlock guarantees
4. Adding a TLA+ model, formally specifying and verifying the guarantees of the new spinlock.
5. Renaming the old lock to `TWriterStarvingRWSpinLock`, and replacing all usages inside YT with the new version (renaming all usages outside of YT to the WriterStarving version).

This is a second attempt of REVIEW: 8233768, the first one was rolled back as it lead to deadlocks in user code with reentrant reader locks:
the case of `AcquireReader(thread0) -&gt; AcquireWriter(thread1) -&gt; AcquireReader(thread0)` is a deadlock, as `thread0` will not be able to acquire the lock (for the second time) before `thread1` frees writer lock, and `thread1` will not be able to acquire writer lock before the reader lock will be released by `thread0`, which won't happen until `thread0` acquires the lock for the second time. See/for more context and a real example of such situation. Analogous problem can happen with fibers: this is why you shouldn't allow context switches under the lock.

Wondering why this ugly name `WriterStarvingRWSpinLock` appeared in your beautiful code? No worries, if you are **sure** that you don't use reentrant locks or fiber switches under the lock, you can freely replace your usage with the new `ReaderWriterSpinLock`. The replacement is drop-in.

[nodiff:caesar]
commit_hash:97683f854defca00cc283f5a2a10a1730b3c9174
</content>
</entry>
<entry>
<title>Throw on error in TNotificationHandle::TNotificationHandle instead of crashing</title>
<updated>2024-08-11T07:50:18Z</updated>
<author>
<name>babenko</name>
<email>babenko@yandex-team.com</email>
</author>
<published>2024-08-11T07:31:25Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=ccd1e498e726a5d05b17b7c451d63da5c9d845ef'/>
<id>urn:sha1:ccd1e498e726a5d05b17b7c451d63da5c9d845ef</id>
<content type='text'>
4356fc70f6d9ceec9f94b1879f49e27f3fee4342
</content>
</entry>
<entry>
<title>Active spinlock tracking from pr3151306. Added TracelessGuards to disable mentioned tracking</title>
<updated>2023-11-16T15:51:45Z</updated>
<author>
<name>arkady-e1ppa</name>
<email>arkady-e1ppa@yandex-team.com</email>
</author>
<published>2023-11-16T14:24:02Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=6b40f0f1060a3e9d54347e52c7dc8fb278e6e86b'/>
<id>urn:sha1:6b40f0f1060a3e9d54347e52c7dc8fb278e6e86b</id>
<content type='text'>
1) Добавлена возможность инструментировать ваш любимый мьютекс/спинлок/что-либо с методами Acquire/Release со схожим смыслом. Делается это засчет методов ```NThreading::NDetail::RecordSpinlockAcquired```/```NThreading::NDetail::RecordSpinlockReleased```. Они отслеживают число захваченных спинлоков.

2) Добавлен макрос ```REGISTER_TRACKED_SPIN_LOCK_CLASS```, который позволяет номинально проверить на этапе компиляции, что данный спинлок отслеживается.

3) Добавлен метод ```NThreading::VerifyNoSpinlockAffinity```, который коркается, если число захваченных спинлоков больше нуля.

4) Добавлены Traceless версии (почти) всех гардов, чтобы можно было не отслеживать конкретную критическую секцию, если очень нужно.

5) Внутри файберного ```WaitUntilSet``` вызывается ```VerifyNoSpinlockAffinity``` -- делать ```WaitFor``` или ```Yield``` внутри отслеживаемых критических секций нельзя. Если очень хочется -- используем TracelessGuard нужного вида.

6) Теперь отслеживаются такие спинлоки и их наследники: ```TSpinLock```, ```TRecursiveSpinLock```, ```TReaderWriterSpinLock```.

7) Зарегистрированы как отслеживаемые все вышеперечисленные спинлоки и их Padded версии.

8) Все эти действия имеют эффект только в дебаг сборке. В релизе вся эта диагностика стирается.
</content>
</entry>
<entry>
<title>add ymake export to ydb</title>
<updated>2023-06-13T08:05:01Z</updated>
<author>
<name>alexv-smirnov</name>
<email>alex@ydb.tech</email>
</author>
<published>2023-06-13T08:05:01Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0'/>
<id>urn:sha1:bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Revert ymake build from ydb oss export</title>
<updated>2023-03-28T19:25:04Z</updated>
<author>
<name>alexv-smirnov</name>
<email>alex@ydb.tech</email>
</author>
<published>2023-03-28T19:25:04Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=b8a17f9b1c166d2e9a26b99348a4c29d972caf55'/>
<id>urn:sha1:b8a17f9b1c166d2e9a26b99348a4c29d972caf55</id>
<content type='text'>
</content>
</entry>
<entry>
<title>add library/cpp/actors, ymake build to ydb oss export</title>
<updated>2023-03-15T16:59:12Z</updated>
<author>
<name>alexv-smirnov</name>
<email>alex@ydb.tech</email>
</author>
<published>2023-03-15T16:59:12Z</published>
<link rel='alternate' type='text/html' href='https://code.mastervirt.ru/ydb/commit/?id=056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11'/>
<id>urn:sha1:056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11</id>
<content type='text'>
</content>
</entry>
</feed>
