Skip to content

Commit c401a0e

Browse files
authored
fix perfermance degradation in photon::thread_create (#1043) (#1046)
Signed-off-by: ivanallen <ivan_allen@163.com>
1 parent 34b5bbf commit c401a0e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

thread/thread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,8 @@ R"(
976976
RunQ rq;
977977
if (unlikely(!rq.current))
978978
LOG_ERROR_RETURN(ENOSYS, nullptr, "Photon not initialized in this vCPU (OS thread)");
979-
size_t randomizer = (rand() % 512) * 8;
979+
thread_local uint64_t random_index = 0;
980+
size_t randomizer = (random_index++ % 512) * 8;
980981
// stack contains struct, randomizer space, and reserved_space
981982
size_t least_stack_size = sizeof(thread) + randomizer + 63 + reserved_space;
982983
// at least a whole page for mprotect

0 commit comments

Comments
 (0)