-
Notifications
You must be signed in to change notification settings - Fork 223
Speed up workspace symbol search #3792
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ def from_path(path:, fragment: nil, scheme: "file", load_path_entry: nil) | |
| end | ||
|
|
||
| uri = build(scheme: scheme, path: escaped_path, fragment: fragment) | ||
| uri.raw_path = path | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont think we should do that, we should rather split whole work into platform specifci path unscaping/escaping and then use the right code paths on the right platform, also the result can be cached on the entry level
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The unescaping was done regardless of the platform, and that was the main bottleneck in my profiling. The secondary bottleneck was the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a difference between
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, uri = URI::Generic.from_path(path: "/Users/janko/Library/Application Support")
uri.path # => "/Users/janko/Library/Application%20Support"
uri.raw_path # => "/Users/janko/Library/Application Support"The problem is that with the URI-escaping we lose the information of the valid file path that was passed to I proposed storing the original valid file path to avoid having to do that work. |
||
|
|
||
| if load_path_entry | ||
| uri.require_path = path.delete_prefix("#{load_path_entry}/").delete_suffix(".rb") | ||
|
|
@@ -40,6 +41,8 @@ def from_path(path:, fragment: nil, scheme: "file", load_path_entry: nil) | |
| end | ||
| end | ||
|
|
||
| #: String | ||
| attr_accessor :raw_path | ||
| #: String? | ||
| attr_accessor :require_path | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,17 +20,7 @@ def initialize(global_state, query) | |
| # @override | ||
| #: -> Array[Interface::WorkspaceSymbol] | ||
| def perform | ||
| @index.fuzzy_search(@query).filter_map do |entry| | ||
| uri = entry.uri | ||
| file_path = uri.full_path | ||
|
|
||
| # We only show symbols declared in the workspace | ||
| in_dependencies = file_path && !not_in_dependencies?(file_path) | ||
| next if in_dependencies | ||
|
|
||
| # We should never show private symbols when searching the entire workspace | ||
| next if entry.private? | ||
|
|
||
| fuzzy_search.filter_map do |entry| | ||
| kind = kind_for_entry(entry) | ||
| loc = entry.location | ||
|
|
||
|
|
@@ -44,7 +34,7 @@ def perform | |
| container_name: container.join("::"), | ||
| kind: kind, | ||
| location: Interface::Location.new( | ||
| uri: uri.to_s, | ||
| uri: entry.uri.to_s, | ||
| range: Interface::Range.new( | ||
| start: Interface::Position.new(line: loc.start_line - 1, character: loc.start_column), | ||
| end: Interface::Position.new(line: loc.end_line - 1, character: loc.end_column), | ||
|
|
@@ -53,6 +43,23 @@ def perform | |
| ) | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def fuzzy_search | ||
janko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @index.fuzzy_search(@query) do |entry| | ||
| file_path = entry.uri.raw_path | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if this is the right approach, we could rather cache this on entry level instead of skipping unscapping parser
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do the unescaping at all? We had the full path when building the URI, why reconstruct it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won't work properly because the URI path and file_path aren't the same thing on Windows and our comparison for uri = URI("file:///C:/ruby/something.rb")
# The URI's path is not a valid file path
uri.path # => "/C:/ruby/something.rb"
# It's the handling of `to_standardized_path` that turns it into the correct one
uri.to_standardized_path # => "C:/ruby/something.rb"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, but my understanding is that it's because of the conversion done in |
||
|
|
||
| # We only show symbols declared in the workspace | ||
| in_dependencies = file_path && !not_in_dependencies?(file_path) | ||
| next if in_dependencies | ||
|
|
||
| # We should never show private symbols when searching the entire workspace | ||
| next if entry.private? | ||
|
|
||
| true | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.