Repository navigation
Propagate doNotProfile state when cloning nodes - #7615
Conversation
|
Patch currently makes the change in Lines 2750 to 2785 in 1c2b08d Alternatively, we could do this in Lines 310 to 346 in 1c2b08d Alternatively, we could do this in the Lines 232 to 306 in 1c2b08d There is a As far as I can tell, semantically |
|
I would prefer changing the copy constructors you mentioned for wider reach, but will ask @hzongaro opinion too. |
|
@vijaysun-omr wrote:
I agree with that assessment, but I'm trying to understand what led to code in It seems OSR support in the JIT is using that flag in its bookkeeping. I'd have to dig deeper to understand whether changing that would cause any problems, but perhaps @vijaysun-omr has some recollection. |
|
I think if the IL opcode was possible to be different without changing the bytecode information (that seems possible with the other node constructor in the PR that @hzongaro linked to), then I can see potential OSR issues. But if a straight copy is done of the node passed in to the node constructor, I don't see an obvious OSR issue. Younes was only proposing changing the "do not profile" property for nodes that did not change the IL opcode. I don't have any history beyond this reasoning and the discussion in that other PR you linked to @hzongaro |
|
Thanks, @vijaysun-omr. Given what you've said, I think it would be fine for the copy constructor to copy the doNotProfile setting in situations where the opcode does not change. |
|
OSR uses the Transformations that create such a situation should be statically pretty rare, i.e. they shouldn't happen in many places in the compiler codebase With involuntary OSR, such transformations can't be done at all, since there's no way to guarantee that OSR won't be attempted With voluntary OSR, it's only possible before the fear analysis, which happens very early. After that point, we're not allowed to introduce any new invalidation points. And if before fear analysis we do something to interfere with OSR, then it restricts where fear points can be placed and therefore also restricts the possible transformations that can be made based on OSR assumptions I think the type of transformation this is meant to notice is one that invents new calls, e.g. one that changes a call into a series of two or more calls. In that case, all of the calls are OSR invalidation points, but only the last one could be an OSR induction point Reading some of the discussion on #3030, the change to set So for OSR purposes, I think that copies created by block splitter (or similar, e.g. loop replicator) are equivalent to their respective originals. This kind of copying will generally happen after the fear analysis anyway, so it shouldn't be able to affect whether OSR can actually happen at the copy. It is important though that we're copying not just the node but the entire block with its related control flow, so that any following OSR guard is copied along with it. Copying a node in isolation could represent some kind of reordering, which could constitute a "new" node from an OSR point of view. However, regardless of how we treat |
BlockSplitter uses BlockCloner to split blocks along hot paths, with the duplicated blocks forming the new hot path (that can then be straightened) and the original blocks being pushed out to cold paths. BlockCloner clones nodes using one of TR::Node's copy constructors, and all Node constructors (copy or otherwise) set doNotProfile on the new node's bytecode info. Setting the doNotProfile flag avoids inadvertantly profiling semantically unrelated nodes that happen to share the same bytecode, thereby polluting the profiling data. The flag also has implications for OSR. Because of the above, when BlockSplitter runs, nothing on the hot path will be profiled, and in cases where the cold paths are never executed, we will completely miss out on profiling information. Because the Node copy constructors are duplicating nodes they don't need to worry about polluting the profiling data and should propagate the doNotProfile flag state to the nodes they duplicate. Signed-off-by: Younes Manton <ymanton@ca.ibm.com>
c8a506a to
7ecce7b
Compare
|
@hzongaro I can run tests after your review (and mine) are done. |
|
Jenkins build all |
|
Tests have passed. Reviews are done. Merging. |
BlockSplitter uses BlockCloner to split blocks along hot paths, with the duplicated blocks forming the new hot path (that can then be straightened) and the original blocks being pushed out to cold paths.
BlockCloner clones nodes using one of TR::Node's copy constructors, which sets the doNotProfile on the clone's bytecode info. The copy constructors are used all over the place, not just to create copies of the original node but to also create new nodes. Setting the doNotProfile flag avoids inadvertantly proflining semantically unrelated nodes that happen to share the same bytecode, thereby polluting the profiling data.
Because of the above, when BlockSplitter runs, nothing on the hot path will be profiled, and in cases where the cold paths are never executed, we will completely miss out on profiling information. Because BlockSplitter and BlockCloner are duplicating nodes they don't need to worry about polluting the profiling data and should propagate the doNotProfile flag state to the nodes they duplicate.