-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Report number of instructions executed since SourceKit was started in statistics request #37450
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
[SourceKit] Report number of instructions executed since SourceKit was started in statistics request #37450
Conversation
swiftlang/swift-stress-tester#150 @swift-ci Please SourceKit stress test |
@swift-ci Please test |
@swift-ci Please test Windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is global anyway, have you considered adding it to the source.request.statistics
request instead of doing it per-request? There are important cases you can't measure per-request like the AST built during an edit request, which happens asynchronously. You could still measure those by calling statistics before the edit and then again after the semantic update notification is received.
Alternatively, if we really need it to be per-request, I think we should wrap it in a dictionary to leave ourselves room for adding more statistics without affecting the top-level response dictionary.
{
... response ...
key.statistics: {
key.instruction_count: Int
}
}
and make the key to enable it more generic, like key.enable_request_statistics
.
@@ -59,6 +57,16 @@ bool environmentVariableRequestedMaximumDeterminism() { | |||
return false; | |||
} | |||
|
|||
uint64_t getInstructionsExecuted() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: It's nice to write swift::
explicitly to ensure it matches the header declaration.
@benlangmuir I hadn’t thought about using the statistics request like that but that sounds like a good idea. We just need to make sure that the overhead of the statistics request doesn’t skew our measurements. I’ll see how much overhead the statistics request adds tomorrow. If the results are comparable, I’ll change it. |
5aeb127
to
848ad2b
Compare
Using the statistics request was an excellent idea. Greatly simplified this PR and also didn’t make the changes in the stress tester much more complex. I measured how much overhead the two statistics requests add to the instruction count and it appears to be negligible, as expected (average of the equivalent of 0.4ms, with some extremes going up to 3ms) |
…s started in statistics request This can be used to measure how many instructions a request executes by retrieving the number of instructions executed since the process’s start before and after executing the request.
848ad2b
to
e8b5bca
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
To measure code completion performance, add an option to tell
sourcekitd
to count the number of instructions it executed for a code completion request.Since this is counting the number of instructions executed by the entire process, this only works reliably if a single request is executed at a time. It is the client's responsibility to ensure that. For now, this is fine because the intended user of this option is the stress tester, which only issues a single request per SourceKit instance anyway.
Eventually, with swiftlang/swift-stress-tester#150 and swiftlang/swift-source-compat-suite#539 merged, this will allow us to time the duration code completion requests took in the stress tester and generate an analysis like the following.
Output