Skip to content

Commit 61573e2

Browse files
fix perfermance degradation in photon::thread_create (#1043) (#1046) (#1047)
Signed-off-by: ivanallen <ivan_allen@163.com> Co-authored-by: Allen <ivan_allen@163.com>
1 parent 5e1a1a5 commit 61573e2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

thread/thread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,8 @@ R"(
10241024
RunQ rq;
10251025
if (unlikely(!rq.current))
10261026
LOG_ERROR_RETURN(ENOSYS, nullptr, "Photon not initialized in this vCPU (OS thread)");
1027-
size_t randomizer = (rand() % 512) * 8;
1027+
thread_local uint64_t random_index = 0;
1028+
size_t randomizer = (random_index++ % 512) * 8;
10281029
// stack contains struct, randomizer space, and reserved_space
10291030
size_t least_stack_size = sizeof(thread) + randomizer + 63 + reserved_space;
10301031
// at least a whole page for mprotect

0 commit comments

Comments
 (0)