Skip to content
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

Add syntax type and definiens to visualization #359

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hendrikvanantwerpen
Copy link
Collaborator

  • Do not serialize empty spans
  • Add syntax type to visualization
  • Serialize definiens span and add to visualization

@hendrikvanantwerpen hendrikvanantwerpen requested a review from a team as a code owner December 1, 2023 13:07
@hendrikvanantwerpen hendrikvanantwerpen self-assigned this Dec 1, 2023
Copy link

github-actions bot commented Dec 1, 2023

Performance Summary

Comparing base 1b01a8c with head c8ee438 on typescript_benchmark benchmark. For details see workflow artifacts. Note that performance is tested on the last commits with changes in stack-graphs, not on every commit.

Before
--------------------------------------------------------------------------------
Command:            base/target/release/tree-sitter-stack-graphs-typescript index -D base.sqlite --max-file-time=30 --hide-error-details -- base/data/typescript_benchmark
Massif arguments:   --massif-out-file=perf.out
ms_print arguments: --x=72 --y=12 base-perf-results/perf.out
--------------------------------------------------------------------------------


    GB
1.702^                                             ::::#                      
     |                                             :   #                      
     |                                             :   #                      
     |                                             :   #                     :
     |                                           @@:   #                    ::
     |                                        :::@ :   #                    ::
     |                                        : :@ :   #                ::::::
     |                                       :: :@ :   #                :   ::
     |                                @ @   ::: :@ :   #         ::     :   ::
     |                                @:@   ::: :@ :   #       @::: :::::   ::
     |              :  ::@     :     :@:@:::::: :@ :   #       @:::@::: :   ::
     |             @:::::@::::::: : ::@:@:::::: :@ :   #   @  :@:::@::: :   ::
   0 +----------------------------------------------------------------------->Gi
     0                                                                   74.56
After
--------------------------------------------------------------------------------
Command:            head/target/release/tree-sitter-stack-graphs-typescript index -D head.sqlite --max-file-time=30 --hide-error-details -- head/data/typescript_benchmark
Massif arguments:   --massif-out-file=perf.out
ms_print arguments: --x=72 --y=12 head-perf-results/perf.out
--------------------------------------------------------------------------------


    GB
1.406^                                                #                       
     |                                                #                      :
     |                                             :::#                      :
     |                                            ::  #                     ::
     |                                          ::::  #                     ::
     |                                          : ::  #                 ::::::
     |                                          : ::  #                 :   ::
     |                                   @    ::: ::  #          :     @:   ::
     |                    @            ::@:   : : ::  #         ::   ::@:   ::
     |              @@  ::@            : @: : : : ::  #       ::::  :: @:   ::
     |              @ ::::@  :        @: @::::: : ::  #       : :::::: @:   ::
     |             @@ ::::@  ::::::   @: @::::: : ::  #      @: :::::: @:   ::
   0 +----------------------------------------------------------------------->Gi
     0                                                                   71.17

@robrix
Copy link
Contributor

robrix commented Dec 1, 2023

Should empty spans include ones where the start and end are equal?

@hendrikvanantwerpen
Copy link
Collaborator Author

Should empty spans include ones where the start and end are equal?

Good question. My thinking was that an empty span starting beyond 0:0 means that that information was explicitly set. Now I realize that an empty span at 0:0 sometimes has been explicitly set as well. An example is a module name with empty_source_span set.

So the test was intended to correspond to "the span was explicitly set", but now it seems we cannot reliably do it.

We could make the spans optional, like syntax type, so that we have an explicit signal. But at that point, it might be more idiomatic to have separate supplemental arenas for the different fields of source info...

@hendrikvanantwerpen
Copy link
Collaborator Author

@dcreager I tried using is empty and starts at zero to detect whether a span or definiens span was actually set by the user. However, we realized that this is not valid.

If I wanted to make that explicit, I see two options:

  1. Similarly to syntax type, we wrap the spans in Option. The downside is that we'll always allocate the memory, even if we don't set those fields for most nodes.

  2. Split source info into multiple arenas. I hoped that this might also result in improved memory behavior, but I think supplemental arena's are regular vectors, not sparse vectors, and we'd allocate still for all nodes that don't get a value set in the end.

What are your thoughts here? Perhaps the planned changes to lsp positions are also relevant to this?

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.

2 participants