Count constraint-solving memory more precisely, rdar://29684330#7088
Conversation
|
The second bit of accounting here is perhaps debatable, and I'd appreciate conceptual double-checking by someone who has thought longer about this. It seems to me that it's more truthy to consider this (very large) temporary vector-of-objects it's building as "part of" the solver's memory use, but an argument could be made the other way. In any case it seems to behave much better with this patch! |
|
I added a new metric that is enabled when !Swift3, and I think we need to look at making sure these issues are fixed on that path as well. A couple things I noticed when I was debugging one of these cases (but didn't have a chance to really look into in detail):
Can you take a look at that path and see what's happening? |
DougGregor
left a comment
There was a problem hiding this comment.
This generally looks good, but aren't we still missing the distinction between "failed because I found no solutions" and "failed because I hit a threshold"?
b920064 to
f2b6eff
Compare
|
Updated with memory high-water mark to at least make the memory-pressure-based judgment sticky; this means it now reports "too complex" properly in both swift 3 and 4 modes. Re: feedback from @DougGregor, yes, it seems that the existing system doesn't differentiate those cases in the return codes, but it does check the "too-complex-ness" of an unsolved constraint system during salvage, when revisiting it in CSDiag. I just needed to make that property sticky so that it doesn't get judged too-complex in CSSolver and not-too-complex in CSDiag. Will try looking into the questions @rudkx asks above wrt. the non-memory signals. Initial scan of Meanwhile, running tests! |
|
@swift-ci please smoke test |
f2b6eff to
5938d84
Compare
5938d84 to
c15c2c2
Compare
|
@swift-ci please test |
|
Build failed |
|
Build failed |
c15c2c2 to
9cb1c52
Compare
rudkx
left a comment
There was a problem hiding this comment.
LGTM.
Thanks for looking into this!
|
@swift-ci please smoke test and merge |
1 similar comment
|
@swift-ci please smoke test and merge |
The type constraint solver guides some of its thinking about when to give up on a
sub-problem by measuring its use of memory. Unfortunately it wasn't measuring that
number very accurately, which meant that it kept going far longer than it should have
on certain cases (and chewed up far too much real memory in the process).
This fixes two points of mis-measurement: the solver-arena's bump allocator (which isn't
actually counted in the existing
getTotalMemorycall) and, more critically, the cost ofthe vector of solutions being accumulated itself.
rdar://29684330