Skip to content

Commit

Permalink
ActorSystem fix typo (ydb-platform#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitaisreal authored and adameat committed Dec 29, 2023
1 parent 491dd86 commit 232ce1e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions ydb/library/actors/core/executor_pool_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace NActors {
ThreadCount = MaxThreadCount;
auto semaphore = TSemaphore();
semaphore.CurrentThreadCount = ThreadCount;
Semaphore = semaphore.ConverToI64();
Semaphore = semaphore.ConvertToI64();
}

TBasicExecutorPool::TBasicExecutorPool(const TBasicExecutorPoolConfig& cfg, IHarmonizer *harmonizer)
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace NActors {
TSemaphore semaphore = TSemaphore::GetSemaphore(x);;
if (semaphore.CurrentSleepThreadCount < 0) {
semaphore.CurrentSleepThreadCount++;
x = AtomicGetAndCas(&Semaphore, semaphore.ConverToI64(), x);
x = AtomicGetAndCas(&Semaphore, semaphore.ConvertToI64(), x);
if (x == oldX) {
*needToWait = true;
*needToBlock = true;
Expand All @@ -140,7 +140,7 @@ namespace NActors {
if (semaphore.CurrentSleepThreadCount == AtomicLoad(&ThreadCount)) {
AllThreadsSleep.store(true);
}
x = AtomicGetAndCas(&Semaphore, semaphore.ConverToI64(), x);
x = AtomicGetAndCas(&Semaphore, semaphore.ConvertToI64(), x);
if (x == oldX) {
*needToWait = true;
*needToBlock = false;
Expand Down Expand Up @@ -285,12 +285,12 @@ namespace NActors {

do {
needToWakeUp = semaphore.CurrentSleepThreadCount > SharedExecutorsCount;
i64 oldX = semaphore.ConverToI64();
i64 oldX = semaphore.ConvertToI64();
semaphore.OldSemaphore++;
if (needToWakeUp) {
semaphore.CurrentSleepThreadCount--;
}
x = AtomicGetAndCas(&Semaphore, semaphore.ConverToI64(), oldX);
x = AtomicGetAndCas(&Semaphore, semaphore.ConvertToI64(), oldX);
if (x == oldX) {
break;
}
Expand Down Expand Up @@ -495,14 +495,14 @@ namespace NActors {
i16 prevCount = GetThreadCount();
AtomicSet(ThreadCount, threads);
TSemaphore semaphore = TSemaphore::GetSemaphore(AtomicGet(Semaphore));
i64 oldX = semaphore.ConverToI64();
i64 oldX = semaphore.ConvertToI64();
semaphore.CurrentThreadCount = threads;
if (threads > prevCount) {
semaphore.CurrentSleepThreadCount += (i64)threads - prevCount;
} else {
semaphore.CurrentSleepThreadCount -= (i64)prevCount - threads;
}
AtomicAdd(Semaphore, semaphore.ConverToI64() - oldX);
AtomicAdd(Semaphore, semaphore.ConvertToI64() - oldX);
LWPROBE(ThreadCount, PoolId, PoolName, threads, MinThreadCount, MaxThreadCount, DefaultThreadCount);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/actors/core/executor_pool_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace NActors {
// Sign bit
i16 CurrentThreadCount = 0; // 14 bits

inline i64 ConverToI64() {
inline i64 ConvertToI64() {
i64 value = (1ll << 34) + OldSemaphore;
return value
| (((i64)CurrentSleepThreadCount + (1 << 14)) << 35)
Expand Down
12 changes: 6 additions & 6 deletions ydb/library/actors/core/executor_pool_basic_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,21 @@ Y_UNIT_TEST_SUITE(BasicExecutorPool) {
TBasicExecutorPool::TSemaphore semaphore;
semaphore = TBasicExecutorPool::TSemaphore::GetSemaphore(0);

VALUES_EQUAL(0, semaphore.ConverToI64());
VALUES_EQUAL(0, semaphore.ConvertToI64());
semaphore = TBasicExecutorPool::TSemaphore::GetSemaphore(-1);
VALUES_EQUAL(-1, semaphore.ConverToI64());
VALUES_EQUAL(-1, semaphore.ConvertToI64());
semaphore = TBasicExecutorPool::TSemaphore::GetSemaphore(1);
VALUES_EQUAL(1, semaphore.ConverToI64());
VALUES_EQUAL(1, semaphore.ConvertToI64());

for (i64 value = -1'000'000; value <= 1'000'000; ++value) {
VALUES_EQUAL(TBasicExecutorPool::TSemaphore::GetSemaphore(value).ConverToI64(), value);
VALUES_EQUAL(TBasicExecutorPool::TSemaphore::GetSemaphore(value).ConvertToI64(), value);
}

for (i8 sleepThreads = -10; sleepThreads <= 10; ++sleepThreads) {

semaphore = TBasicExecutorPool::TSemaphore();
semaphore.CurrentSleepThreadCount = sleepThreads;
i64 initialValue = semaphore.ConverToI64();
i64 initialValue = semaphore.ConvertToI64();

semaphore = TBasicExecutorPool::TSemaphore::GetSemaphore(initialValue - 1);
VALUES_EQUAL(-1, semaphore.OldSemaphore);
Expand All @@ -257,7 +257,7 @@ Y_UNIT_TEST_SUITE(BasicExecutorPool) {
semaphore = TBasicExecutorPool::TSemaphore();
semaphore.OldSemaphore = expected;
semaphore.CurrentSleepThreadCount = sleepThreads;
UNIT_ASSERT_VALUES_EQUAL(semaphore.ConverToI64(), value);
UNIT_ASSERT_VALUES_EQUAL(semaphore.ConvertToI64(), value);
value++;
}

Expand Down
4 changes: 2 additions & 2 deletions ydb/library/actors/core/ut_fat/actor_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(HeavyActorBenchmark) {
threadsList.push_back(threads);
}
std::vector<ui32> actorPairsList = {512};
TActorBenchmark::RunSendActivateReceiveCSV(threadsList, actorPairsList, {1,100, 200}, TDuration::Seconds(1));
TActorBenchmark::RunSendActivateReceiveCSV(threadsList, actorPairsList, {1,100, 200}, TDuration::Seconds(1));
}

Y_UNIT_TEST(StarSendActivateReceiveCSV) {
Expand All @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(HeavyActorBenchmark) {
}
std::vector<ui32> actorPairsList = {512};
std::vector<ui32> starsList = {10};
TActorBenchmark::RunStarSendActivateReceiveCSV(threadsList, actorPairsList, starsList);
TActorBenchmark::RunStarSendActivateReceiveCSV(threadsList, actorPairsList, starsList);
}

}

0 comments on commit 232ce1e

Please sign in to comment.