Skip to content

Conversation

@nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Nov 17, 2017

When bootstrapping dotty, this reduces the allocated FlagSets from 2.7M to 400K.

def union(flagss: FlagSet*) = (EmptyFlags /: flagss)(_ | _)
def union(flagss: FlagSet*): FlagSet = {
var flag = EmptyFlags
for (f <- flagss)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to go deep in micro-optimizations, you could use a while loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should avoid FlagSet* altogether.


/** The union of all flags in given flag set */
def union(flagss: FlagSet*) = (EmptyFlags /: flagss)(_ | _)
def union(flagss: FlagSet*): FlagSet = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still going to box, isn't it? FlagSet* becomes Seq[FlagSet], value classes in generic positions are always boxed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We avoid reboxing in the fold, half of the boxes are gone.

@nicolasstucki
Copy link
Contributor Author

test performance please

@nicolasstucki
Copy link
Contributor Author

I do not believe the performance should change much

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/3497/ to see the changes.

Benchmarks is based on merging with master (b95e71a)

@allanrenucci allanrenucci merged commit e675e6b into scala:master Nov 20, 2017
@allanrenucci allanrenucci deleted the some-micro-opts branch December 14, 2017 19:24
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.

5 participants