Skip to content

Commit

Permalink
Move EventPipe thread buffer allocation outside of lock (#67936)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Salem authored May 2, 2022
1 parent 7ce9845 commit 463be3a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/native/eventpipe/ep-buffer-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,12 @@ buffer_manager_allocate_buffer_for_thread (
EP_ASSERT(buffer_size > 0);
ep_return_null_if_nok(buffer_manager_try_reserve_buffer(buffer_manager, buffer_size));

// Allocating a buffer requires us to take the lock.
// The sequence counter is exclusively mutated on this thread so this is a thread-local read.
sequence_number = ep_thread_session_state_get_volatile_sequence_number (thread_session_state);
new_buffer = ep_buffer_alloc (buffer_size, ep_thread_session_state_get_thread (thread_session_state), sequence_number);
ep_raise_error_if_nok (new_buffer != NULL);

// Adding a buffer to the buffer list requires us to take the lock.
EP_SPIN_LOCK_ENTER (&buffer_manager->rt_lock, section1)
thread_buffer_list = ep_thread_session_state_get_buffer_list (thread_session_state);
if (thread_buffer_list == NULL) {
Expand All @@ -513,11 +518,6 @@ buffer_manager_allocate_buffer_for_thread (
thread_buffer_list = NULL;
}

// The sequence counter is exclusively mutated on this thread so this is a thread-local read.
sequence_number = ep_thread_session_state_get_volatile_sequence_number (thread_session_state);
new_buffer = ep_buffer_alloc (buffer_size, ep_thread_session_state_get_thread (thread_session_state), sequence_number);
ep_raise_error_if_nok_holding_spin_lock (new_buffer != NULL, section1);

if (buffer_manager->sequence_point_alloc_budget != 0) {
// sequence point bookkeeping
if (buffer_size >= buffer_manager->remaining_sequence_point_alloc_budget) {
Expand Down

0 comments on commit 463be3a

Please sign in to comment.