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
[SR-11767] IDE completion tests have quadratic performance #54174
Comments
@swift-ci create |
Hey DaveZ! Could you show us an example of a trace exhibiting this behaviour? I'm not clear where you're seeing the repeated conversions from line+column to offset. I've seen offset -> line+column conversions show up in traces before, but never line+column -> offset, and never in code-completion. The only such translation I can think of for code-completion would be for the `-pos=N:M` command-line argument to the invocation of sourcekitd-test. |
From perf record/report of the slowest IDE test (complete_value_expr.swift):
And the busy code scanning for newlines:
|
Thanks! This looks like it is happening in the new serialized location code proposed here https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794. @nkcsgexi We should make sure this code is efficient in general, but is there a way for us to turn it off completely in code-completion? |
@nkcsgexi how about storing the utf8 byte offset instead of line:column, so we don't have to pay the cost of resolving all these line:column locations. |
Talked with @akyrtzi more about this, we could set `IgnoreSwiftSourceInfo = true` for all code completion invocation. Probably even for all sourcekitd invocations? |
It's probably useful to have them available for locations in the emitted diagnostics (live issues). |
@nathawes has completely disabled serialized location functionality for code-completion please verify with using latest snapshots from master or swift-5.2 branch. |
Additional Detail from JIRA
md5: 916052869301b0c69a030ac96fb056bb
Issue Description:
If I'm reading the trace results of `perf` (on Linux) correctly, the IDE completion test cases have quadratic performance. The problem seems to be that nothing caches where the line breaks are in a source file, so every time a line+column pair is translated back to a source location, the source file is rescanned. This is especially true if the line+column lookup fails and `None` is returned. The code also doesn't even call `memchr()` to find the next newline (`memchr` is vector optimized, at least on Linux).
The text was updated successfully, but these errors were encountered: