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

Disable typechecking on the name attribute for TypedObject. #116

Merged
merged 1 commit into from
Jul 5, 2021

Conversation

connorshea
Copy link
Contributor

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:

Screen Shot 2021-07-05 at 1 20 56 PM

After:

Screen Shot 2021-07-05 at 1 21 59 PM

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).

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.
@AaronC81
Copy link
Owner

AaronC81 commented Jul 5, 2021

Thank you!

@AaronC81 AaronC81 merged commit 3ba701c into AaronC81:master Jul 5, 2021
@connorshea connorshea deleted the perf-improvement-typed-object branch July 5, 2021 20:03
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.

None yet

2 participants