ce5c0b0727 (Jason Zaugg, 2 minutes ago) Encapsulate TypeHistory mutation and remove obviated optimization adaptInfos#73
Closed
ce5c0b0727 (Jason Zaugg, 2 minutes ago) Encapsulate TypeHistory mutation and remove obviated optimization adaptInfos#73
Conversation
Monitoring compilation with a flight recorder, we noticed that the compiler allocates a lot of TypeHistory objects. TO reduce those allocations: - We extract a variable for the special `TypeHistory` instance that is used at the beginning, with "NoType" type. - We make all class fields mutable: when we are adding a new "root" (no previous history), we avoid creating a new "TypeHistory" and instead "rewrite" the existing one.
diesalbla
reviewed
Oct 14, 2019
|
|
||
| // OPT: mutate the current TypeHistory rather than creating a new one. TypeHistory instances should not be shared. | ||
| final def reset(validFrom: Period, info: Type): TypeHistory = { | ||
| if (this ne noTypeHistory) TypeHistory(validFrom, info, null) |
There was a problem hiding this comment.
I think this has the branches switched... because NoTypeHistory is a constant to be shared, that is the one that should never be mutated.
retronym
commented
Oct 15, 2019
|
|
||
| // OPT: mutate the current TypeHistory rather than creating a new one. TypeHistory instances should not be shared. | ||
| final def reset(validFrom: Period, info: Type): TypeHistory = { | ||
| if (this ne noTypeHistory) TypeHistory(validFrom, info, null) |
Owner
Author
There was a problem hiding this comment.
You're right, I got this if the wrong way around.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
6659f90 (Diego E. Alonso Blas, 5 hours ago)
TypeHistory: use mutability to avoid allocations.
Monitoring compilation with a flight recorder, we noticed that the compiler
allocates a lot of TypeHistory objects. TO reduce those allocations:
TypeHistoryinstance thatis used at the beginning, with "NoType" type.
"root" (no previous history), we avoid creating a new "TypeHistory"
and instead "rewrite" the existing one.