Skip to content

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Apr 16, 2021

Improve performance of getAThrownException, by restricting to relevant methods.

Before (`mono/mono`)
[2021-04-16 12:43:59] (2136s) Clause timing report:
[2021-04-16 12:43:59] (2136s) 
[2021-04-16 12:43:59] 
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::getAThrownException#ff .............................. 6m0s (39 evaluations with max 30.6s in DisposeNotCalledOnException::getAThrownException#ff/2@i12#778d5w)
	DisposeNotCalledOnException.ql-30:#Assignable::AssignableRead::getANextRead_dispred#fbPlus ......................... 9.3s (552 evaluations with max 2.2s in #Assignable::AssignableRead::getANextRead_dispred#fbPlus/2@i2#b4f66w)
	DisposeNotCalledOnException.ql-30:Location::Location::hasLocationInfo_dispred#ffffff ............................... 2.4s
	DisposeNotCalledOnException.ql-30:DataFlowPublic::ExprNode::getExpr_dispred#ff ..................................... 2.3s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_120#join_rhs ............ 2.2s
	DisposeNotCalledOnException.ql-30:locations_default_102345#join_rhs ................................................ 2.1s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_20#join_rhs ............. 2s
	DisposeNotCalledOnException.ql-30:Call::Call::getARuntimeTarget_dispred#fb_10#join_rhs ............................. 2s
	DisposeNotCalledOnException.ql-30:m#Assignable::nameOfChild#fb ..................................................... 2s (21 evaluations with max 963ms in m#Assignable::nameOfChild#fb/1@i3#f572cw)
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_201#join_rhs ............ 1.9s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getType_dispred#ff ................................................... 1.9s (3 evaluations with max 1.6s in Expr::Expr::getType_dispred#ff/2@i1#fb72dw)
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::localFlowStep#ff#antijoin_rhs ....................... 1.9s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getNode_dispred#fff_201#join_rhs ........................ 1.8s
	DisposeNotCalledOnException.ql-30:Stmt::getAChild#ffb .............................................................. 1.8s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getASuccessor_dispred#ff ................................ 1.8s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getNode_dispred#fff ..................................... 1.8s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChildExpr_dispred#fff_120#join_rhs ........ 1.8s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getType_dispred#ff_10#join_rhs ....................................... 1.6s
	DisposeNotCalledOnException.ql-30:expressions_20#join_rhs .......................................................... 1.6s
	DisposeNotCalledOnException.ql-30:project#BasicBlocks::BasicBlock::getNode_dispred#fff_10#join_rhs ................. 1.5s
	DisposeNotCalledOnException.ql-30:expressions_10#join_rhs .......................................................... 1.5s
	DisposeNotCalledOnException.ql-30:Assignable::AssignableDefinition::getAReachableRead_dispred#fb ................... 1.5s
	DisposeNotCalledOnException.ql-30:project#ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_10#join_rhs ..... 1.5s
	DisposeNotCalledOnException.ql-30:Stmt::TryStmt::definitelyHandles_dispred#fff#antijoin_rhs ........................ 1.4s
	DisposeNotCalledOnException.ql-30:project#Element::Element::toString_dispred ....................................... 1.3s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChildExpr_dispred#fff ..................... 1.3s
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::localFlowStep#ff_10#join_rhs ........................ 1.3s
	DisposeNotCalledOnException.ql-30:project#BasicBlocks::BasicBlock::getNode_dispred#fff ............................. 1.3s
	DisposeNotCalledOnException.ql-30:Assignable::AssignableRead#f ..................................................... 1.2s
	DisposeNotCalledOnException.ql-30:Assignable::nameOfChild#fb#join_rhs .............................................. 1.2s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getEnclosingCallable#ff .............................................. 1.2s
	DisposeNotCalledOnException.ql-30:project#ExprOrStmtParent::ExprOrStmtParent::getChildExpr_dispred#fff_10#join_rhs . 1.2s
	DisposeNotCalledOnException.ql-30:project#Stmt::getAChild#ffb_10#join_rhs .......................................... 1.1s
	DisposeNotCalledOnException.ql-30:Stmt::TryStmt::getATriedElement#fb#join_rhs ...................................... 1.1s
	DisposeNotCalledOnException.ql-30:Expr::ThrowElement::getExpr#ff ................................................... 1.1s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getNode_dispred#fff_021#join_rhs ........................ 1.1s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getEnclosingCallable_dispred#ff ...................................... 1s
	DisposeNotCalledOnException.ql-30:Stmt::TryStmt::definitelyHandles_dispred#fff ..................................... 1s
	DisposeNotCalledOnException.ql-30:ControlFlowGraph::ControlFlow::Node::getBasicBlock_dispred#ff .................... 951ms
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::length_dispred#ff ....................................... 933ms
	DisposeNotCalledOnException.ql-30:m#Stmt::TryStmt::getATriedElement#fb ............................................. 925ms (27 evaluations with max 272ms in m#Stmt::TryStmt::getATriedElement#fb/1@i3#42193w)
	DisposeNotCalledOnException.ql-30:ControlFlowGraph::ControlFlow::Node_not_AnnotatedExitNode_EntryNode_ExitNode#f ... 886ms
	DisposeNotCalledOnException.ql-30:Location::Location::getFile_dispred#ff ........................................... 870ms
	DisposeNotCalledOnException.ql-30:Dispose::LocalScopeDisposableCreation#class#f .................................... 790ms
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff ......................... 788ms
	DisposeNotCalledOnException.ql-30:project#ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff ................. 672ms
	DisposeNotCalledOnException.ql-30:project#ControlFlowGraphImpl::Cached::getASuccessorByType ........................ 644ms
	DisposeNotCalledOnException.ql-30:ControlFlowElement::ControlFlowElement::getEnclosingCallable_dispred#ff .......... 634ms
	DisposeNotCalledOnException.ql-30:DataFlowPublic::ExprNode#class#f ................................................. 617ms
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::localFlowStep#ff .................................... 599ms
After (`mono/mono`)
[2021-04-16 15:05:16] (1924s) Clause timing report:
[2021-04-16 15:05:16] (1924s) 
[2021-04-16 15:05:16] 
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::RelevantMethod::getAThrownException#ff .............. 1m6s (39 evaluations with max 5.6s in DisposeNotCalledOnException::RelevantMethod::getAThrownException#ff/2@i12#53149w)
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::RelevantMethod::callsNoTry#ff ....................... 11s
	DisposeNotCalledOnException.ql-30:#Assignable::AssignableRead::getANextRead_dispred#fbPlus ......................... 10.5s (552 evaluations with max 2.5s in #Assignable::AssignableRead::getANextRead_dispred#fbPlus/2@i2#b4f66w)
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::RelevantMethod#class#f#shared ....................... 4.2s
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::RelevantMethod#class#f#join_rhs ..................... 3.3s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::Cached::bestLocation#ff_10#join_rhs ............................ 3s
	DisposeNotCalledOnException.ql-30:Location::Location::hasLocationInfo_dispred#ffffff ............................... 2.9s
	DisposeNotCalledOnException.ql-30:DataFlowPublic::ExprNode::getExpr_dispred#ff ..................................... 2.8s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getNode_dispred#fff ..................................... 2.7s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_20#join_rhs ............. 2.6s
	DisposeNotCalledOnException.ql-30:locations_default_102345#join_rhs ................................................ 2.6s
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::localFlowStep#ff#antijoin_rhs ....................... 2.4s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getNode_dispred#fff_201#join_rhs ........................ 2.4s
	DisposeNotCalledOnException.ql-30:m#Assignable::nameOfChild#fb ..................................................... 2.4s (21 evaluations with max 1.1s in m#Assignable::nameOfChild#fb/1@i3#f572cw)
	DisposeNotCalledOnException.ql-30:Stmt::getAChild#ffb .............................................................. 2.4s
	DisposeNotCalledOnException.ql-30:Call::Call::getARuntimeTarget_dispred#fb_10#join_rhs ............................. 2.4s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_120#join_rhs ............ 2.3s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getType_dispred#ff ................................................... 2.2s (3 evaluations with max 1.9s in Expr::Expr::getType_dispred#ff/2@i1#fb72dw)
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChildExpr_dispred#fff_120#join_rhs ........ 2.2s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_201#join_rhs ............ 2.1s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getASuccessor_dispred#ff ................................ 2.1s
	DisposeNotCalledOnException.ql-30:project#BasicBlocks::BasicBlock::getNode_dispred#fff_10#join_rhs ................. 2s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getType_dispred#ff_10#join_rhs ....................................... 1.9s
	DisposeNotCalledOnException.ql-30:Stmt::TryStmt::definitelyHandles_dispred#fff#antijoin_rhs ........................ 1.9s
	DisposeNotCalledOnException.ql-30:project#ExprOrStmtParent::ExprOrStmtParent::getChild_dispred#fff_10#join_rhs ..... 1.9s
	DisposeNotCalledOnException.ql-30:ControlFlowGraph::ControlFlow::Node::getBasicBlock_dispred#ff_10#join_rhs ........ 1.7s
	DisposeNotCalledOnException.ql-30:expressions_20#join_rhs .......................................................... 1.7s
	DisposeNotCalledOnException.ql-30:Element::Element::fromLibrary_dispred#b .......................................... 1.7s
	DisposeNotCalledOnException.ql-30:Assignable::AssignableDefinition::getAReachableRead_dispred#fb ................... 1.7s
	DisposeNotCalledOnException.ql-30:expressions_10#join_rhs .......................................................... 1.7s
	DisposeNotCalledOnException.ql-30:DisposeNotCalledOnException::localFlowStep#ff_10#join_rhs ........................ 1.7s
	DisposeNotCalledOnException.ql-30:project#Element::Element::toString_dispred ....................................... 1.6s
	DisposeNotCalledOnException.ql-30:File::Container::getBaseName_dispred#ff .......................................... 1.6s
	DisposeNotCalledOnException.ql-30:project#BasicBlocks::BasicBlock::getNode_dispred#fff ............................. 1.6s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getEnclosingCallable_dispred#ff_10#join_rhs .......................... 1.6s
	DisposeNotCalledOnException.ql-30:ExprOrStmtParent::ExprOrStmtParent::getChildExpr_dispred#fff ..................... 1.5s
	DisposeNotCalledOnException.ql-30:Assignable::nameOfChild#fb#join_rhs .............................................. 1.5s
	DisposeNotCalledOnException.ql-30:Stmt::TryStmt::getATriedElement#fb#join_rhs ...................................... 1.5s
	DisposeNotCalledOnException.ql-30:project#Stmt::getAChild#ffb_10#join_rhs .......................................... 1.4s
	DisposeNotCalledOnException.ql-30:Assignable::AssignableRead#f ..................................................... 1.4s
	DisposeNotCalledOnException.ql-30:project#ExprOrStmtParent::ExprOrStmtParent::getChildExpr_dispred#fff_10#join_rhs . 1.4s
	DisposeNotCalledOnException.ql-30:Stmt::TryStmt::definitelyHandles_dispred#fff ..................................... 1.3s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getEnclosingCallable#ff .............................................. 1.3s
	DisposeNotCalledOnException.ql-30:Expr::ThrowElement::getExpr#ff ................................................... 1.3s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::getNode_dispred#fff_021#join_rhs ........................ 1.2s
	DisposeNotCalledOnException.ql-30:BasicBlocks::BasicBlock::length_dispred#ff ....................................... 1.2s
	DisposeNotCalledOnException.ql-30:Expr::Expr::getEnclosingCallable_dispred#ff ...................................... 1.2s
	DisposeNotCalledOnException.ql-30:ControlFlowGraph::ControlFlow::Node::getBasicBlock_dispred#ff .................... 1.1s
	DisposeNotCalledOnException.ql-30:m#Stmt::TryStmt::getATriedElement#fb ............................................. 1.1s (27 evaluations with max 348ms in m#Stmt::TryStmt::getATriedElement#fb/1@i3#42193w)
	DisposeNotCalledOnException.ql-30:Location::Location::getFile_dispred#ff ........................................... 1s

https://jenkins.internal.semmle.com/job/Changes/job/CSharp-Differences/1012/

@github-actions github-actions bot added the C# label Apr 16, 2021
@hvitved hvitved marked this pull request as ready for review April 19, 2021 07:21
@hvitved hvitved requested a review from a team as a code owner April 19, 2021 07:21
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Apr 19, 2021
@hvitved hvitved merged commit 1f92390 into github:main Apr 20, 2021
@hvitved hvitved deleted the csharp/dispose-not-called-on-exc-perf branch April 20, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants