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

Make source a field in Positioned nodes #9900

Merged
merged 10 commits into from
Oct 3, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 28, 2020

The purpose of the PR is to revise the source pos scheme so that no global data structures are needed. There seems to be no way other than to simply add the source file as a field to each tree.

Fixes #9738

@odersky
Copy link
Contributor Author

odersky commented Sep 28, 2020

test performance please

@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/9900/ to see the changes.

Benchmarks is based on merging with master (d084b8b)

@odersky
Copy link
Contributor Author

odersky commented Sep 28, 2020

test performance please

@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merging with master (d084b8b)

@odersky
Copy link
Contributor Author

odersky commented Sep 28, 2020

If we take take the average of the two benchmark runs we get a ~1% deterioration for 3 of the 4 compilation test and a ~1% improvement for the last (re2). So it looks like nothing much to worry about.

@odersky
Copy link
Contributor Author

odersky commented Sep 28, 2020

test performance please

@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/9900/ to see the changes.

Benchmarks is based on merging with master (09eaed7)

Tree ids cannot be garbage collected, so they are prone to overflow for long-running compilation sessions.
Therefore, we should not rely on tree ids except for debugging.
Instead, keep a separate weak hashmap if a tree-id option is set.
Since tree ids are now only used for debugging, we do not need to
maintain them as an inline field anymore.
@odersky odersky marked this pull request as ready for review September 30, 2020 20:43
@odersky
Copy link
Contributor Author

odersky commented Sep 30, 2020

test performance please

@dottybot
Copy link
Member

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

@odersky
Copy link
Contributor Author

odersky commented Sep 30, 2020

Trees now have a source field instead of a uniqueId, so their size does not change. Unique ids can still be obtained via a weak hashmap if -Yshow-tree-ids or -Ydebug-tree-with-id is set. Since trees are no longer mappable to ints, we cannot use SparseArrays in pickling anymore. For now, we reverted back to an IdentityHashMap, which means all stored addresses are boxed. We could improve on this with a different custom data structure. Another improvement down the line would be to pass sources when we set the tree's span instead of right away. That would simplify tree creation infrastructure quite a lot since no implicit argument would have to be passed.

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merging with master (c40ef6e)

IntMap[Key] is conceptually like a Map[Key, Int]. For now, only
`apply` and `update` are supported but `remove` is not supported.

The map is implemented by means of a perfect hashing scheme that is
itself implemented in the parent class `PerfectHashing`. This maps
keys to indices in a dense interval. Once we have the index, we can
associate keys and values that are simply stored in arrays.
@odersky
Copy link
Contributor Author

odersky commented Oct 1, 2020

test performance please

@dottybot
Copy link
Member

dottybot commented Oct 1, 2020

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

which is no longer needed
Size it so that it corresponds roughly with the initial size of the buffer.
@dottybot
Copy link
Member

dottybot commented Oct 1, 2020

Performance test finished successfully:

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

Benchmarks is based on merging with master (c40ef6e)

@odersky
Copy link
Contributor Author

odersky commented Oct 1, 2020

test performance please

Code taken from scala.collection.mutable.AnyRefMap
@dottybot
Copy link
Member

dottybot commented Oct 1, 2020

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

@odersky
Copy link
Contributor Author

odersky commented Oct 1, 2020

test performance please

@dottybot
Copy link
Member

dottybot commented Oct 1, 2020

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

@dottybot
Copy link
Member

dottybot commented Oct 1, 2020

Performance test finished successfully:

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

Benchmarks is based on merging with master (19cf871)

@dottybot
Copy link
Member

dottybot commented Oct 1, 2020

Performance test finished successfully:

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

Benchmarks is based on merging with master (94970a0)

@odersky
Copy link
Contributor Author

odersky commented Oct 1, 2020

That's the first instalment of the source position changes. We make source position a field and remove all usages of uniqueId except for debugging. This should fix #9738.

There's scope for further changes. namely to pass sources when we also set the span of a tree. It turns out that's a lot trickier to do, so we will defer this to a separate PR.

@odersky odersky added this to the 3.0.0-M1 milestone Oct 2, 2020
Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

The new scheme is a clear improvement over the old one. Just forgot to remove some field.

odersky and others added 2 commits October 3, 2020 14:03
Co-authored-by: Nicolas Stucki <nicolas.stucki@gmail.com>
Co-authored-by: Nicolas Stucki <nicolas.stucki@gmail.com>
@odersky odersky merged commit e2ade80 into scala:master Oct 3, 2020
@odersky odersky deleted the fix-sourcepos branch October 3, 2020 14:10
mbovel added a commit that referenced this pull request Sep 30, 2021
mbovel added a commit to dotty-staging/dotty that referenced this pull request Sep 30, 2021
olsdavis pushed a commit to olsdavis/dotty that referenced this pull request Apr 4, 2022
@Kordyjan Kordyjan modified the milestones: 3.0.0-M1, 3.0.0 Aug 2, 2023
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.

dotc: Error: requirement failed: array index too large, maximum is 2^30 - 1
4 participants