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

SI-9157 Avoid exponential blowup with chained type projections #4341

Merged
merged 1 commit into from
Feb 18, 2015

Conversation

retronym
Copy link
Member

Calling findMember in the enclosed test was calling into
NonClassTypeRef#relativeInfo an exponentially-increasing number
of times, with respect to the length of the chained type projections.

The numbers of calls increased as: 26, 326, 3336, 33446, 334556.
Can any pattern spotters in the crowd that can identify the
sequence? (I can't.)

Tracing the calls saw we were computing the same memberType
repeatedly. This part of the method was not guarded by the cache.

I have changed the method to use the standard idiom of using the
current period for cache invalidation. The enclosed test now compiles
promptly, rather than in geological time.

@scala-jenkins scala-jenkins added this to the 2.11.6 milestone Feb 18, 2015
@retronym retronym force-pushed the ticket/9157 branch 3 times, most recently from 6e4cba8 to b826f9e Compare February 18, 2015 04:16
Calling `findMember` in the enclosed test was calling into
`NonClassTypeRef#relativeInfo` an exponentially-increasing number
of times, with respect to the length of the chained type projections.

The numbers of calls increased as: 26, 326, 3336, 33446, 334556.
Can any pattern spotters in the crowd that can identify the sequence?
(I can't.)

Tracing the calls saw we were computing the same `memberType`
repeatedly. This part of the method was not guarded by the cache.

I have changed the method to use the standard idiom of using the
current period for cache invalidation. The enclosed test now compiles
promptly, rather than in geological time.
@retronym
Copy link
Member Author

Review by @adriaanm

@jrudolph
Copy link
Member

Here's an iterative formula for the pattern:

x_0 = 26
x_n = 56 + 10 * (x_{n-1} + n)

@adriaanm
Copy link
Contributor

LGTM! I can feel the tectonic plates zipping past! Chrome feels snappier too! And I haven't even merged!

And, @jrudolph, wow -- just wow!

adriaanm added a commit that referenced this pull request Feb 18, 2015
SI-9157 Avoid exponential blowup with chained type projections
@adriaanm adriaanm merged commit ea17de1 into scala:2.11.x Feb 18, 2015
@lrytz
Copy link
Member

lrytz commented Feb 19, 2015

@jrudolph smarter than alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants