yiguolei commented on code in PR #11404:
URL: https://github.com/apache/doris/pull/11404#discussion_r935019504
##########
be/src/runtime/memory/chunk_allocator.cpp:
##########
@@ -86,14 +88,23 @@ class ChunkArena {
int idx = BitUtil::Log2Ceiling64(size);
auto& free_list = _chunk_lists[idx];
- std::lock_guard<SpinLock> l(_lock);
- if (free_list.empty()) {
- return false;
+ if (free_list.empty()) return false;
+
+ for (int i = 0; i < TRY_LOCK_TIMES; ++i) {
+ if (_lock.try_lock()) {
Review Comment:
Have you tested concurrency? For example, 10 threads call pop free chunk
concurrently.
Because in spin lock it will try to call try lock 70 times and then wait.
// Acquires the lock, spins until the lock becomes available
void lock() {
for (int spin_count = 0; !try_lock(); ++spin_count) {
if (spin_count < NUM_SPIN_CYCLES) {
#if (defined(__i386) || defined(__x86_64__))
asm volatile("pause\n" : : : "memory");
#elif defined(__aarch64__)
asm volatile("yield\n" ::: "memory");
#endif
} else {
sched_yield();
spin_count = 0;
}
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]