Re: Moving threadstate to thread-local storage.
25 Feb
2021
25 Feb
'21
3:52 a.m.
On MacOS & iOS, __thread variable is 35% faster than using pthread_getspecific. getSpecific cost: 0.000649 getTLS cost: 0.000423 - (void)test { double t1 = CFAbsoluteTimeGetCurrent(); for (int i = 0; i < 100000; i++) { [self getSpecific]; } double t2 = CFAbsoluteTimeGetCurrent(); printf("getSpecific cost: %f\n", t2 - t1); double t3 = CFAbsoluteTimeGetCurrent(); for (int i = 0; i < 100000; i++) { [self getTLS]; } double t4 = CFAbsoluteTimeGetCurrent(); printf("getTLS cost: %f\n", t4 - t3); } - (int)getSpecific { int * value = pthread_getspecific(tlsKey); return *value; } - (int)getTLS { return *tlv_v5; }
1126
Age (days ago)
1127
Last active (days ago)
1 comments
2 participants
participants (2)
-
Victor Stinner
-
谢俊逸