Skip to content

MacOS managed debugging perf fix#39804

Merged
mikem8361 merged 5 commits intodotnet:masterfrom
mikem8361:macperf
Jul 25, 2020
Merged

MacOS managed debugging perf fix#39804
mikem8361 merged 5 commits intodotnet:masterfrom
mikem8361:macperf

Conversation

@mikem8361
Copy link
Contributor

@mikem8361 mikem8361 commented Jul 22, 2020

Issue: #12706

This PR adds PAL_OpenProcessMemory, PAL_ReadProcessMemory and PAL_CloseProcessMemory that
encapsulate the remote read memory functions for both MacOS and Linux.

The DBI code that reads memory using the runtime IPC messages to use these new functions
and fallback to the IPC message if the open fails.

On MacOS, this won't have any affect on VSCode performance until vsdbg/vsdbgui are signed
with the "com.apple.security.cs.debugger" entitlement.

Sample entitlements.plist file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.debugger</key>
      <true/>
  </dict>
</plist>

Example of locally signing with entitlement command:

codesign -s <local-cert> --entitlements entitlements.plist

This PR adds PAL_OpenProcessMemory, PAL_ReadProcessMemory and PAL_CloseProcessMemory that
encapsulate the remote read memory functions for both MacOS and Linux.

The DBI code that reads memory using the runtime IPC messages to use these new functions
and fallback to the IPC message if the open fails.

On MacOS, this won't have any affect on VSCode performance until vsdbg/vsdbgui are signed
with the "com.apple.security.cs.debugger" entitlement.

Sample entitlements.plist file:

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.debugger</key>
      <true/>
  </dict>
</plist>
```

Example of locally signing with entitlement command:

codesign -s <local-cert> --entitlements entitlements.plist
@ghost
Copy link

ghost commented Jul 22, 2020

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

@mikem8361 mikem8361 requested a review from janvorli July 22, 2020 23:22
…bugging uses faster OOP unwind for HelpMethodFrames
@mikem8361 mikem8361 requested a review from hoyosjs July 23, 2020 20:24
@mikem8361
Copy link
Contributor Author

@hoyosjs Jan is on vacation. Could you review?

@hoyosjs
Copy link
Member

hoyosjs commented Jul 23, 2020

@hoyosjs Juan Sebastian Hoyos Ayala FTE Jan is on vacation. Could you review?

yup, will need to test so I'll check later today.

@mikem8361
Copy link
Contributor Author

I have tested under VSCode for Linux and no regressions. On MacOS VSCode I get 3x perf improvement on my simple perf test project.

@mikem8361
Copy link
Contributor Author

@hoyosjs are you going to get to reviewing this today?

@mikem8361 mikem8361 requested a review from hoyosjs July 24, 2020 23:48
Copy link
Member

@hoyosjs hoyosjs left a comment

Choose a reason for hiding this comment

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

LGTM


exit:
free(data);
if (data != nullptr)
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this check, but doesn't harm either.

@ghost
Copy link

ghost commented Jul 25, 2020

Hello @mikem8361!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@mikem8361 mikem8361 merged commit 6ca6003 into dotnet:master Jul 25, 2020
@mikem8361 mikem8361 deleted the macperf branch July 25, 2020 04:01
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
* MacOS managed debugging perf fix

This PR adds PAL_OpenProcessMemory, PAL_ReadProcessMemory and PAL_CloseProcessMemory that
encapsulate the remote read memory functions for both MacOS and Linux.

The DBI code that reads memory using the runtime IPC messages to use these new functions
and fallback to the IPC message if the open fails.

On MacOS, this won't have any affect on VSCode performance until vsdbg/vsdbgui are signed
with the "com.apple.security.cs.debugger" entitlement.

Sample entitlements.plist file:

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.debugger</key>
      <true/>
  </dict>
</plist>
```

Example of locally signing with entitlement command:

codesign -s <local-cert> --entitlements entitlements.plist

Fix FreeBSD build. Remove FEATURE_DATATARGET4 for macOS so managed debugging uses faster OOP unwind for HelpMethodFrames
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants