Skip to content

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Jun 7, 2023

Since DocumentHighlight focuses on the type of the visited node instead of the visiting event, I think it makes sense to introduce a new on_visit event for it. It saves us from expanding the nodes list in HighlightTarget into a list of fragmented on_<node> events.

It should also benefit other requests that currently define the visit method.

Motivation

Implementation

Automated Tests

Manual Tests

@st0012 st0012 added this to the 2023-Q2 milestone Jun 7, 2023
@st0012 st0012 self-assigned this Jun 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2023

Benchmark results in seconds (slowest at top)

          textDocument/completion average: 0.260739 std_dev: 0.00525
          textDocument/diagnostic average: 0.043481 std_dev: 0.008692
      textDocument/selectionRange average: 0.00342 std_dev: 0.000649
   textDocument/documentHighlight average: 0.001832 std_dev: 0.000148
 textDocument/semanticTokens/full average: 0.001728 std_dev: 0.000337
      textDocument/documentSymbol average: 0.001728 std_dev: 9.2e-05
            textDocument/codeLens average: 0.001723 std_dev: 0.000186
        textDocument/documentLink average: 0.001717 std_dev: 0.000173
        textDocument/foldingRange average: 0.001601 std_dev: 0.000103
textDocument/semanticTokens/range average: 0.000889 std_dev: 5.8e-05
               codeAction/resolve average: 0.000662 std_dev: 9.8e-05
               textDocument/hover average: 0.000621 std_dev: 8.7e-05
           textDocument/inlayHint average: 0.00061 std_dev: 6.3e-05
    textDocument/onTypeFormatting average: 0.000118 std_dev: 7.7e-05
          textDocument/formatting average: 7.3e-05 std_dev: 0.000304
          textDocument/codeAction average: 4.0e-05 std_dev: 3.3e-05


================================================================================
Comparison with main branch:

 textDocument/semanticTokens/full unchanged
textDocument/semanticTokens/range slower by 12.46 %
      textDocument/documentSymbol unchanged
        textDocument/foldingRange unchanged
          textDocument/formatting unchanged
          textDocument/diagnostic unchanged
        textDocument/documentLink unchanged
           textDocument/inlayHint slower by 16.504 %
      textDocument/selectionRange unchanged
   textDocument/documentHighlight slower by 24.3 %
               textDocument/hover unchanged
          textDocument/codeAction unchanged
    textDocument/onTypeFormatting unchanged
               codeAction/resolve unchanged
          textDocument/completion unchanged
            textDocument/codeLens unchanged


At least one benchmark is slower than the main branch.

@st0012 st0012 force-pushed the st0012-#664 branch 3 times, most recently from 5028e4f to 91b11a7 Compare June 8, 2023 15:00
@st0012
Copy link
Member Author

st0012 commented Jun 8, 2023

I've rerun benchmark around 8 times and documentHighlight is consistently ~25% slower, so I think it's safe to say this approach causes performance regression. But I'm not sure why this is the case 🤔

@st0012 st0012 mentioned this pull request Jun 9, 2023
Since DocumentHighlight focuses on the type of the visited node instead
of the visiting event, I think it makes sense to introduce a new `on_node`
event for it. It saves us from expanding the nodes list in HighlightTarget
into a list of fragmented `on_<node>` events.

It should also benefit other requests that currently define the
`visit` method.
@st0012
Copy link
Member Author

st0012 commented Jun 19, 2023

Wrt the slowdown, I notice that it also happens to other migration PRs:

So it's likely not specific to this change. We should look into what's causing the slowdown though OR if our benchmark is too sensitive.

@st0012 st0012 marked this pull request as ready for review June 19, 2023 12:19
@st0012 st0012 requested a review from a team as a code owner June 19, 2023 12:19
@st0012 st0012 requested review from andyw8 and vinistock June 19, 2023 12:19
Comment on lines +48 to +55
highlight_target =
case target
when *DIRECT_HIGHLIGHTS
Support::HighlightTarget.new(target)
when SyntaxTree::Ident
relevant_node = parent.is_a?(SyntaxTree::Params) ? target : parent
Support::HighlightTarget.new(relevant_node)
end
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker, but just a thought: what if we move this to Executor? Would that maybe simplify things a bit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Consider the data type it uses (HighlightTarget) is still specific to this request, I prefer keeping it at the same place until we share it somewhere else.

@st0012 st0012 merged commit 3d78133 into main Jun 19, 2023
@st0012 st0012 deleted the st0012-#664 branch June 19, 2023 20:42
@shopify-shipit shopify-shipit bot temporarily deployed to production June 23, 2023 15:44 Inactive
vinistock added a commit that referenced this pull request Feb 28, 2024
Time out tests that don't finish under 30 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants