Skip to content

opcache JIT: Adds initial support for macOs Instruments performance #8914

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
wants to merge 1 commit into from
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
43 changes: 43 additions & 0 deletions ext/opcache/jit/zend_jit_perf_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <fcntl.h>

#if !defined(__APPLE__)
#if defined(__linux__)
#include <sys/syscall.h>
#elif defined(__darwin__)
Expand Down Expand Up @@ -274,3 +275,45 @@ static void zend_jit_perf_map_register(const char *name, void *start, size_t siz
}
fprintf(fp, "%zx %zx %s\n", (size_t)(uintptr_t)start, size, name);
}
#else
#include <os/log.h>
#include <os/signpost.h>

static os_log_t jitdump_fd;
static os_signpost_id_t jitdump_sp = OS_SIGNPOST_ID_NULL;

static void zend_jit_perf_jitdump_open(void)
{
/**
* The `os_log_t` list per namespace is maintained by the os
* and are not deallocated by (and not deallocatable)
* but are reusable.
*/
jitdump_fd = os_log_create("net.php.opcache.jit", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
jitdump_sp = os_signpost_id_generate(jitdump_fd);

if (jitdump_sp != OS_SIGNPOST_ID_NULL && jitdump_sp != OS_SIGNPOST_ID_INVALID) {
os_signpost_interval_begin(jitdump_fd, jitdump_sp, "zend_jitdump");
}
}

static void zend_jit_perf_jitdump_close(void)
{
if (jitdump_sp != OS_SIGNPOST_ID_NULL && jitdump_sp != OS_SIGNPOST_ID_INVALID) {
os_signpost_interval_end(jitdump_fd, jitdump_sp, "zend_jitdump");
}
}

static void zend_jit_perf_jitdump_register(const char *name, void *start, size_t size)
{
}

static void zend_jit_perf_map_register(const char *name, void *start, size_t size)
{
os_signpost_id_t map = os_signpost_id_make_with_pointer(jitdump_fd, start);
if (map != OS_SIGNPOST_ID_NULL && map != OS_SIGNPOST_ID_INVALID) {
os_signpost_event_emit(jitdump_fd, map, "zend_jitdump_name", "%s", name);
os_signpost_event_emit(jitdump_fd, map, "zend_jitdump_size", "%lu", size);
}
}
#endif