Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Speed up fgLocalVarLiveness in minopts. #12665

Merged
merged 4 commits into from
Jul 10, 2017
Merged

Conversation

pgavlin
Copy link

@pgavlin pgavlin commented Jul 6, 2017

In particular:

  • Do not re-sort lclVars
  • Do not run LVA
  • Do not set mustInit
  • Do not set last uses
  • Do not perform DSE

@pgavlin
Copy link
Author

pgavlin commented Jul 6, 2017

@dotnet-bot
test Windows_NT x86 Checked minopts
test Windows_NT minopts

@dotnet dotnet deleted a comment from dotnet-bot Jul 6, 2017
In particular, do not re-sort lclVars, run LVA, or run DSE.
@pgavlin pgavlin force-pushed the LivenessMinOpts branch from c940cf0 to 26a0220 Compare July 6, 2017 16:04
@pgavlin
Copy link
Author

pgavlin commented Jul 6, 2017

dotnet-bot
test Windows_NT x86 Checked minopts
test Windows_NT minopts
test OSX10.12 minopts
test Ubuntu minopts

@pgavlin
Copy link
Author

pgavlin commented Jul 6, 2017

@BruceForstall @CarolEidt any thoughts? This is worth another couple percent on Bruce's dataset at the cost of never issuing early kills for lclVars. Note that this cost may actually be zero, as IIUC we do not issue early kills today due to Peter's JitMinOptsTrackGCrefs work.

@CarolEidt
Copy link

Do not re-sort lclVars
Do not run LVA
Do not set last uses and perform DSE

It seems that this currently does only the first, unless I am missing something (since the code to disable liveness is under #if CAN_DISABLE_DFA which doesn't seem to have been defined anywhere).

I think it looks good, and takes it a step further than my WIP/deferred work on simply disabling tracking of non-user lclVars.

@@ -1323,6 +1322,13 @@ class LiveVarAnalysis

void Compiler::fgLiveVarAnalysis(bool updateInternalOnly)
{
#if CAN_DISABLE_DFA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case where we think CAN_DISABLE_DFA would be false?
Also, I think the condition below should be made consistent with what the register allocator is doing, i.e. it should be if(compiler->opts.compFlags & CLFLG_REGVAR) != 0) here, and presumably m_lsra->enregisterLocalVars in Lowering. Otherwise, we should simply set LinearScan::enregisterLocalVars to false always under minopts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently CAN_DISABLE_DFA is never false. We could probably just remove the symbol entirely--I only used it in because these changes depend on the minopts-only code in fgPerBlockLocalVarLiveness that is also conditional on this symbol.

I agree that we should keep this consistent with the allocator's decisions, though I think that minopts should remain a part of the condition as liveness is also used by DSE and the emitter. I think the appropriate condition under which to disable these operations is if (opts.MinOpts() && !enregisterLocalVars).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow - I didn't realize there was a CAN_DISABLE_DFA symbol!

I agree that we should keep this consistent with the allocator's decisions, though I think that minopts should remain a part of the condition as liveness is also used by DSE and the emitter. I think the appropriate condition under which to disable these operations is if (opts.MinOpts() && !enregisterLocalVars).

I agree about including minopts. Note, though, that enregisterLocalVars isn't available in liveness.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was considering adding a parameter to fgLocalVarLiveness to communicate that info.

pgavlin added 2 commits July 10, 2017 11:41
And cut out a little bit more of liveness that does not need to run if
we're not enregistering lclVars.
@pgavlin
Copy link
Author

pgavlin commented Jul 10, 2017

@dotnet-bot
test Windows_NT x86 Checked minopts
test Windows_NT minopts
test OSX10.12 minopts
test Ubuntu minopts

Copy link

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo what seems to be a mistaken negation.

@@ -4588,7 +4588,7 @@ void Lowering::DoPhase()
// For now we'll take the throughput hit of recomputing local liveness but in the long term
// we're striving to use the unified liveness computation (fgLocalVarLiveness) and stop
// computing it separately in LSRA.
if (comp->lvaCount != 0)
if ((comp->lvaCount != 0) && !comp->backendRequiresLocalVarLifetimes())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be if ((comp->lvaCount != 0) && comp->backendRequiresLocalVarLifetimes())?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes--good catch.

@pgavlin
Copy link
Author

pgavlin commented Jul 10, 2017

@dotnet-bot
test Windows_NT x86 Checked minopts
test Windows_NT minopts
test OSX10.12 minopts
test Ubuntu minopts

@pgavlin pgavlin changed the title [WIP] Speed up fgLocalVarLiveness in minopts. Speed up fgLocalVarLiveness in minopts. Jul 10, 2017
@pgavlin pgavlin merged commit 848b3af into dotnet:master Jul 10, 2017
@pgavlin pgavlin deleted the LivenessMinOpts branch July 10, 2017 20:43
@karelz karelz modified the milestone: 2.1.0 Aug 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants