Skip to content

Fix zend_jit_stop_counter_handlers() performance issues with protect_memory=1 #11323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ext/opcache/jit/zend_jit_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7175,8 +7175,6 @@ static void zend_jit_stop_hot_trace_counters(zend_op_array *op_array)
uint32_t i;

jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(op_array);
zend_shared_alloc_lock();
SHM_UNPROTECT();
for (i = 0; i < op_array->last; i++) {
/* Opline with Jit-ed code handler is skipped. */
if (jit_extension->trace_info[i].trace_flags &
Expand All @@ -7188,8 +7186,6 @@ static void zend_jit_stop_hot_trace_counters(zend_op_array *op_array)
op_array->opcodes[i].handler = jit_extension->trace_info[i].orig_handler;
}
}
SHM_PROTECT();
zend_shared_alloc_unlock();
}

/* Get the tracing op_array. */
Expand Down Expand Up @@ -7228,6 +7224,9 @@ static void zend_jit_stop_persistent_script(zend_persistent_script *script)
/* Get all scripts which are accelerated by JIT */
static void zend_jit_stop_counter_handlers(void)
{
zend_shared_alloc_lock();
/* mprotect has an extreme overhead, avoid calls to it for every function. */
SHM_UNPROTECT();
for (uint32_t i = 0; i < ZCSG(hash).max_num_entries; i++) {
zend_accel_hash_entry *cache_entry;
for (cache_entry = ZCSG(hash).hash_table[i]; cache_entry; cache_entry = cache_entry->next) {
Expand All @@ -7237,6 +7236,8 @@ static void zend_jit_stop_counter_handlers(void)
zend_jit_stop_persistent_script(script);
}
}
SHM_PROTECT();
zend_shared_alloc_unlock();
}

static void zend_jit_blacklist_root_trace(const zend_op *opline, size_t offset)
Expand Down