Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Capture Performance Telemetry #39

Closed
DonJayamanne opened this issue Feb 5, 2018 · 11 comments
Closed

Capture Performance Telemetry #39

DonJayamanne opened this issue Feb 5, 2018 · 11 comments
Assignees
Milestone

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Feb 5, 2018

In the recent release of VS Code we introduced some changes to capture some telemetry on the performance of the debugger, specifically:

  • How long it takes to launch the debugger
  • How long it takes for the debugger to break after executing the following commands stepIn, stepOut, continue, next

Now, I don't see any code in PTVSD to capture telemetry. Thats fine.
The problem is we'll need this, without this we cannot measure the performance improvements (and this is a must for the first release).

So the question is:

  • Who'll add this telemetry? PTVSD (debugger) or the adapter (the stuff in the middle) layer?
    If this is something we're going to need for VS as well, then it must be done in PTVS.
@DonJayamanne DonJayamanne changed the title Performance Telemetry Capture Performance Telemetry Feb 5, 2018
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Feb 12, 2018

I thought I could implement this in the vscode adapter layer, unfortunately i need to send a sequence number.

@int19h
Copy link
Contributor

int19h commented Feb 12, 2018

We can certainly do it on ptvsd side of things, but we'll need some proper logging there first in general.

@DonJayamanne
Copy link
Contributor Author

but we'll need some proper logging there first in general.

Looking at the following comment (https://github.com/Microsoft/ptvsd/blob/master/ptvsd/ipcjson.py#L91) I assumed the plan was not to have any logging at that layer. I patched PTVSD to include some logging for my own dev purposes.

@int19h
Copy link
Contributor

int19h commented Feb 12, 2018

Oh, not at all - ipcjson.py comes from the old ptvsd, and I only made minor changes to it to accommodate some unusual attribute names. If you look at wrapper.py, it has some print logging commented out. But the idea is to do the same thing pydevd does - check for a certain environment variable, and log all traffic to the file it specifies if it's there.

@int19h int19h added this to the VSC Public Preview milestone Mar 21, 2018
@MikhailArkhipov MikhailArkhipov modified the milestones: VSC Public Preview, May 2018 May 2, 2018
@MikhailArkhipov MikhailArkhipov modified the milestones: July 2018.1, Future Jul 10, 2018
@karthiknadig karthiknadig removed this from the Future milestone Sep 14, 2018
@qubitron qubitron added this to the Feb 2019.2 milestone Feb 21, 2019
@int19h int19h self-assigned this Feb 26, 2019
@karthiknadig karthiknadig modified the milestones: Feb 2019.2, Mar 2019.1 Mar 4, 2019
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Aug 15, 2019

@int19h @karthiknadig
Please could you add this telemetry. We'll need this to determine whether shipping the wheels does impact improve performance (positive/negative) or not & by how much.

Telemetry for: Time to start debugger, etc.
Obviously we'll need this to compare perf for debugging with & without wheels.

This will be a blocker for us shipping the wheels, as we won't know whether shipping wheels adversely impacts debugger or not (i.e. there's no data)

@int19h
Copy link
Contributor

int19h commented Aug 16, 2019

We need to identify a specific list of metrics.

And some of these will need to be implemented on VSCode side - e.g. time to start the debugger has to be measured on that side, because it includes the process spawn time, which cannot be measured by the process itself. VSCode could measure it by starting a timer when debug session starts, and stopping it when it sees the first "thread" event - this is the most reliable indicator that user code has started running in the debuggee process.

However, binary wheels also affect the execution of user code by improving tracing performance, so we also need to measure that somehow. We could measure the total time spent in user code - i.e. time during which the process isn't paused. But the problem is that for any app that blocks while running (e.g. reads input, or listens for socket connection, or waits for a lock etc), our measurements will include those blocking waits, which will dominate perf.

Then we need to consider multithreading, given that some threads might be paused while others are running, and that GIL really only allows one thread running at a time.

This all needs to be very carefully designed for us to get any meaningful data out of this, and it won't be trivial to implement. We might want to do some manual perf testing first, on specifically written test code with various patterns (which can measure itself with the time module), to see how much telemetry we still need after getting the numbers from that.

@int19h
Copy link
Contributor

int19h commented Aug 16, 2019

One other thing. Our logs already have high-resolution timestamps on every event, which start counting from the moment logging is initialized (which happens right after we parse the command line).

So if you capture a full log, you can see how long the entire debug session took from debugger's perspective, and you can see how long individual events took by comparing timestamps for messages.

For example, to measure a step, you can look at the timestamp for the "stepIn" request, and the timestamp for the "stopped" event that followed - this will correspond pretty closely to the delay observed by the user in the UI.

@DonJayamanne
Copy link
Contributor Author

So if you capture a full log, you can see how long the entire debug session took from debugger's perspective, and you can see how long individual events took by comparing timestamps for messages

Yes this is possible. However the metrics are for the PM team.
Best discussed separately. I.e. build a tool to extract and compare the values or capture the metrics via debugger telemetry events (and use existing tools).

@fabioz
Copy link
Contributor

fabioz commented Aug 16, 2019 via email

@Anapo14
Copy link
Contributor

Anapo14 commented Aug 16, 2019

Of course having an exact measure of what the user is doing would be ideal. Don and I spoke about this yesterday...for example, if they have some kind of 'sleep' within their code (as just an example), that could muddy the waters, but from a reporting standpoint, as long as we are averaging what is happening across all users I think we should be fine. @DonJayamanne mentioned that this was done in the past. Please let me know if I didn't summarize that correctly, Don.

I think a reasonable first pass is to use existing tools, come to an agreement on what we want to measure, and get it in...unless building the more 'accurate' tool can be done in a reasonable amount of time. I can speak with @qubitron about this next week.

@Anapo14 Anapo14 added this to the September 2019.1 milestone Sep 4, 2019
@Anapo14 Anapo14 assigned karthiknadig and unassigned int19h Sep 4, 2019
@karthiknadig
Copy link
Member

Telemetry to calculate how long it takes to load debugger is done. Any future telemetry items should have separate work items. Also, capturing telemetry from the IDE side using DebugAdapterTracker allows us to capture telemetry without depending on the debugger side changes.

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

No branches or pull requests

7 participants