Skip to content
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

Enable heap profiling on macOS #2314

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

m-seker
Copy link

@m-seker m-seker commented Aug 8, 2022

Enable heap profiling on macOS.

Both prof-libgcc and prof-gcc works with clang on macOS. The library mappings are dumped via dyld API.

@m-seker m-seker force-pushed the osx_heap_profiling branch 4 times, most recently from d508d10 to 42d1314 Compare August 9, 2022 13:05
@@ -4698,7 +4698,7 @@ sub ParseLibraries {
$offset = HexExtend($3);
$lib = $4;
$lib =~ s|\\|/|g; # turn windows-style paths into unix-style paths
} elsif ($l =~ /^\s*($h)-($h):\s*(\S+\.so(\.\d+)*)/) {
} elsif ($l =~ /^\s*($h)-($h):\s*(.*$)/) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Match for library mappings on macOS dump. The library names can have .dylib extension or no extension at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit concerned that the regex is too relaxed. Any idea to tighten the no extension case a bit? It looks space is allowed on macOS.

@@ -1369,7 +1380,7 @@ fi
if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
-a "x$GCC" = "xyes" ; then
AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
if test "x${enable_prof_libgcc}" = "x1" ; then
if test "x${enable_prof_libgcc}" = "x1" -a "x${je_cv_clang}" != "xyes" ; then
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to link with lgcc for clang.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we still perform the _Unwind_Backtrace availability test for clang? Or it's for sure present with unwind.h?

@@ -4698,7 +4698,7 @@ sub ParseLibraries {
$offset = HexExtend($3);
$lib = $4;
$lib =~ s|\\|/|g; # turn windows-style paths into unix-style paths
} elsif ($l =~ /^\s*($h)-($h):\s*(\S+\.so(\.\d+)*)/) {
} elsif ($l =~ /^\s*($h)-($h):\s*(.*$)/) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit concerned that the regex is too relaxed. Any idea to tighten the no extension case a bit? It looks space is allowed on macOS.

@@ -1369,7 +1380,7 @@ fi
if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
-a "x$GCC" = "xyes" ; then
AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
if test "x${enable_prof_libgcc}" = "x1" ; then
if test "x${enable_prof_libgcc}" = "x1" -a "x${je_cv_clang}" != "xyes" ; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we still perform the _Unwind_Backtrace availability test for clang? Or it's for sure present with unwind.h?

typedef int (prof_dump_open_maps_t)();
extern prof_dump_open_maps_t *JET_MUTABLE prof_dump_open_maps;
#endif // __APPLE__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: /* */ for comments

typedef struct segment_command_64 je_dyld_segment_command;

#define JE_DYLD_IMAGE_MAGIC MH_MAGIC_64
#define JE_DYLD_IMAGE_MAGIC_INV MH_CIGAM_64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe _REVERSE or stick to _CIGAM? The _INV feels a bit close to invalid.


TEST_BEGIN(test_mdump_maps_error) {
test_skip_if(!config_prof);
test_skip_if(!config_debug);

prof_dump_open_file_t *open_file_orig = prof_dump_open_file;
prof_dump_write_file_t *write_file_orig = prof_dump_write_file;
#ifndef __APPLE__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It looks we can remove this too?

@@ -128,10 +128,12 @@ TEST_BEGIN(test_mdump_output_error) {
}
TEST_END

#ifndef __APPLE__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not really necessary?

@interwq
Copy link
Member

interwq commented Oct 23, 2023

@m-seker FYI that Sherry @Notdevil will take over here. Thanks for starting this; we'll keep you posted when it becomes available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants