Disable typechecking on the name attribute for TypedObject. #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was having some problems with a SorbetRails plugin where the conflict resolution stage was taking an obscenely long time. This makes that problem significantly less severe.
For my open source Rails app vglist, it consistently decreases the time spent generating type signatures down from 14 seconds to 9 seconds. For a large Rails app, the difference is much more significant. From 750 seconds down to 314 seconds.
I can't share more specific info from the larger app (proprietary and all that), but I can share the flamegraphs for my personal project vglist: https://gist.github.com/connorshea/a6e8c303b8464af90f33b98278fd3276
Unfortunately GitHub Gists don't allow JS inside an SVG to be run (even if you open them as Raw), so if you want to look at them in detail you'll need to save the files locally and view them in your browser from your filesystem (yes I realize that's very sketchy, unfortunately I don't know of a better solution other than hosting these on a website I own, which is too much work lol).
Essentially, the important part is in the
#resolve_conflicts
method.Before this change:
After:
You'll note that the
TypedObject#name
method shows up as a large block of time before, and it's gone afterward.In vglist, the
#resolve_conflicts
method goes from 8,491ms to 3,907ms. In the large Rails app I'm testing with, it cuts the#resolve_conflicts
method down from 611,506ms to 172,784ms.As far as I understand, I think this performance improvement is due to the way that subclasses of TypedObject are compared with one another during conflict resolution to discover and eliminate duplicates. The first thing that always gets compared will be the
name
attribute, and therefore it's called a lot of times (specifically, 4.4 million times in vglist and 258 million times in the large Rails app).