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

Allocate TreeInfo objects using TR::Region of containing List #7305

Merged

Conversation

hzongaro
Copy link
Member

If the findOrCreateTreeInfo function fails to find a TreeInfo object that refers to a particular TR::TreeTop in the targetTrees List, it allocates a new TreeTop instance using trStackMemory. However, findOrCreateTreeInfo is called within a call tree from DeadTreesElimination::process. The process method creates a new TR::StackMemoryRegion on entry to the method, but the targetTrees List has a lifetime that extends for the duration of the optimization. (The _targetTrees is first constructed in the DeadTreesElimination constructor and is only cleared in the prePerformOnBlocks method.

The TreeInfo objects should be allocated from the same TR::Region that the List uses for allocation of its nodes to ensure that their lifetime is as long as that of the containing List object.

Fixes: Issue eclipse-openj9/openj9#19197

@hzongaro
Copy link
Member Author

@vijaysun-omr, may I ask you to review this change?

One thing that isn't absolutely clear to me is whether it's absolutely necessary to allow for the possibility that _targetTrees could contain an entry that refers to a TR::TreeTop that came from an extended block that was processed in a previous call to DeadTreesElimination::process(TR::TreeTop*,TR::TreeTop*). That's effectively what this change does.

I attempted test runs with assertions added to check for that possibility, and did not encounter any assertion failures. However, I don't know whether there's a guarantee that that situation could not arise.

I think this change is safe, but it might be that we could instead narrow the lifetime of _targetTrees so that it — and the TreeInfo objects it contains — could be allocated using the same stack memory region that's created on entry to that process method.

@vijaysun-omr
Copy link
Contributor

Thanks @hzongaro I don't know of a reason why we would want to refer to a tree info for something that was processed in a prior pass of the dead trees elimination optimization (as I think was the gist of your question). This is a bit clunky since the state of the IL trees could have changed to make the "height" calculation wrong in the intervening optimizations.

So I think

I think this change is safe, but it might be that we could instead narrow the lifetime of _targetTrees so that it — and the TreeInfo objects it contains — could be allocated using the same stack memory region that's created on entry to that process method.

is an option to consider.

@hzongaro
Copy link
Member Author

So I think
...
is an option to consider.

Thanks, @vijaysun-omr. I've reviewed the usage of DeadTreesElimination::process(TR::TreeTop*,TR::TreeTop*) and verified that it is safe to allocate the targetTrees List in the in-scope StackMemoryRegion rather than using a longer-lived field associated with the optimization. I've pushed commit 870af4d to make that change. If you are good with it, I will squash the commits.

@vijaysun-omr
Copy link
Contributor

Thanks, you can squash the commits and I can run testing after that.

The _targetTrees List is used to keep track of TR::TreeTops that are
being processed.  In applying the optimization to requested blocks, the
DeadTreesElimination::process(TR::TreeTop*,TR::TreeTop*) method is
called for all TR::TreeTops in an entire extended basic block;
otherwise it is called for all TR::TreeTops in the method.

After the process method returns, TR:TreeTops in that range will not
need to be visited again during the current application of Dead Trees
Elimination, so there's no need to track them in a _targetTrees field
associated with the optimization.  Instead the field can be made into a
local variable in the process method, with memory allocated in the in
scope StackMemoryRegion object.

The TreeInfo objects that are stored in the List by the
findOrCreateTreeInfo function should be allocated from the same
TR::Region that the List uses for allocation of its nodes to ensure that
their lifetime is as long as that of the containing List object.
@hzongaro hzongaro force-pushed the deadTreesElimination-TreeInfo-allocation branch from 870af4d to 149b872 Compare April 22, 2024 18:52
@hzongaro
Copy link
Member Author

Jenkins build all

@vijaysun-omr
Copy link
Contributor

jenkins build riscv

@vijaysun-omr
Copy link
Contributor

jenkins build win

@vijaysun-omr
Copy link
Contributor

jenkins build riscv

@hzongaro
Copy link
Member Author

The riscv failure does not appear to be specific to this pull request:

17:28:16  29/30 Test #29: comptest ..........................Child killed***Exception: 1509.37 sec
17:28:16  test 30
17:28:16        Start 30: compunittest
17:28:16 
...
17:28:16  
17:28:16  97% tests passed, 1 tests failed out of 30
17:28:16  
17:28:16  Total Test time (real) = 1947.83 sec
17:28:16  
17:28:16  The following tests FAILED:
17:28:16  	 29 - comptest (Child killed)
17:28:16  Errors while running CTest 

The same failure appears in this PR build for pull request #7315.

The x86-64 macOS failure appears to be due to known issue #7181.

@vijaysun-omr vijaysun-omr merged commit e2d8e0f into eclipse:master Apr 23, 2024
15 of 18 checks passed
@hzongaro hzongaro deleted the deadTreesElimination-TreeInfo-allocation branch April 23, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants