state tracking by PostOrderNodeIterator, holding to states longer than needed

Lukas Stadler lukas.stadler at oracle.com
Thu May 8 10:04:28 UTC 2014


In general, single compilations (and especially single compilation phases) don’t last very long. Or at least they shouldn’t :-)
Thus the fact that something is still referenced, and therefore cannot be collected, is not an issue.

However, never removing states that aren’t needed any more makes the hash map grow bigger and bigger…
So we could remove them as soon as they aren’t used any more.
Some investigations into whether this is a win would be good.

Going further, it might be a good idea to look some more at how the nodeStates map is used:
- it holds the states for merge and loop ends
- it holds the state for ControlSplit successors that have been queued

For the latter case, the map isn’t really needed at all, since we could have a second queue with the states for queued nodes (or use the more hacky way of making the queue a Queue<Object> and always putting node and state into it).
With those entries out of the way, the map should be created lazily (if end nodes are encountered or by querying graph.hasNode(MergeNode.class)). 

Some of this could also be applied to the other iterators.
There’s definitely room for improvement. On the other hand, it’s a relatively simple and easy to understand piece of code, which is also a good thing… so we should only optimize it if it really is a problem.

- Lukas

On 08 May 2014, at 10:45, Miguel Garcia Gutierrez <miguel.m.garcia at oracle.com> wrote:

> Hi,
> 
> I was thinking about ways to lower the memory-footprint of ConditionalEliminationPhase and FlowSensitiveReductionPhase.
> 
> Both rely on PostOrderNodeIterator that tracks program-state on a per program-point basis. PostOrderNodeIterator is used to realize a single-pass visit of nodes, as opposed to multi-pass as in iterative dataflow.
> 
> (Actually, the "single-pass" property is not intrinsic to PostOrderNodeIterator, but determined by the subclass of MergeableState in use: an override of merge() that always returns true makes PostOderNodeIterator perform a single-pass visit).
> 
> Back to lowering memory-footprint. 
> 
> PostOrderNodeIterator tracks states in a map from FixedNode to state, a map that is used to grab states for loop begins and ends, for merge forward-ends, and for the predecessor of begin-nodes.
> 
> That map is cleared only at the end of the single-pass visit. However, some entries are accessed for a last time well before that. For example, after all forward-ends of a merge have been visited, which entries won't be ever looked up again?
> 
> I'm trying to visualize the above, comments are welcome!
> 
> 
> Miguel



More information about the graal-dev mailing list