Substitute all T::Struct usage for plain Objects #493
Merged
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.
Motivation
I wanted to get a more complete understanding of the LSP's performance on a long running session, so I added the following to
server.rb
to generate profile data.I edited and saved files for 2 minutes to triggered as many requests as possible. To my surprise, of the 120 seconds we spent 30 of them just initializing
T::Struct
objects (specifically, running the construct with defaults thing and performing runtime typechecks withis_a?
).Other than the desire to have very compact class definitions, we really have no other requirement for using
T::Struct
and it doesn't seem like a good trade off for the performance penalty.Using benchmark IPS to check the difference on a single request, not counting objects created for queueing, there's a 7% performance difference.
This also benefits YJIT, which in my local machine goes from 1.24 -> 1.32 interp / yjit ratio.
Implementation
Switched all
T::Struct
to regular classes.