Skip to content

Commit fb9f5c6

Browse files
committed
Improve precision of executed statements.
1 parent 208f25b commit fb9f5c6

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

src/dsql/StmtNodes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,11 @@ class DeclareSubFuncNode : public TypedNode<StmtNode, StmtNode::TYPE_DECLARE_SUB
479479
public:
480480
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp);
481481

482+
virtual bool isProfileAware() const
483+
{
484+
return false;
485+
}
486+
482487
virtual Firebird::string internalPrint(NodePrinter& printer) const;
483488
virtual DeclareSubFuncNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
484489
virtual void genBlr(DsqlCompilerScratch* dsqlScratch);
@@ -532,6 +537,11 @@ class DeclareSubProcNode : public TypedNode<StmtNode, StmtNode::TYPE_DECLARE_SUB
532537
public:
533538
static DmlNode* parse(thread_db* tdbb, MemoryPool& pool, CompilerScratch* csb, const UCHAR blrOp);
534539

540+
virtual bool isProfileAware() const
541+
{
542+
return false;
543+
}
544+
535545
virtual Firebird::string internalPrint(NodePrinter& printer) const;
536546
virtual DeclareSubProcNode* dsqlPass(DsqlCompilerScratch* dsqlScratch);
537547
virtual void genBlr(DsqlCompilerScratch* dsqlScratch);

src/jrd/exe.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,19 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
13651365
SINT64 lastPerfCounter = initialPerfCounter;
13661366
const StmtNode* profileNode = nullptr;
13671367

1368+
const auto profilerCallAfterPsqlLineColumn = [&] {
1369+
const SINT64 currentPerfCounter = fb_utils::query_performance_counter();
1370+
1371+
if (profileNode)
1372+
{
1373+
attachment->getProfilerManager(tdbb)->afterPsqlLineColumn(request,
1374+
profileNode->line, profileNode->column,
1375+
currentPerfCounter - lastPerfCounter);
1376+
}
1377+
1378+
return currentPerfCounter;
1379+
};
1380+
13681381
while (node && !(request->req_flags & req_stall))
13691382
{
13701383
try
@@ -1386,16 +1399,7 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
13861399
(!profileNode ||
13871400
!(node->line == profileNode->line && node->column == profileNode->column)))
13881401
{
1389-
if (profileNode)
1390-
{
1391-
const SINT64 currentPerfCounter = fb_utils::query_performance_counter();
1392-
1393-
attachment->getProfilerManager(tdbb)->afterPsqlLineColumn(request,
1394-
profileNode->line, profileNode->column,
1395-
currentPerfCounter - lastPerfCounter);
1396-
1397-
lastPerfCounter = currentPerfCounter;
1398-
}
1402+
lastPerfCounter = profilerCallAfterPsqlLineColumn();
13991403

14001404
profileNode = node;
14011405

@@ -1408,7 +1412,12 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
14081412
node = node->execute(tdbb, request, &exeState);
14091413

14101414
if (exeState.exit)
1415+
{
1416+
if (attachment->isProfilerActive() && !request->hasInternalStatement())
1417+
request->req_profiler_time += profilerCallAfterPsqlLineColumn() - initialPerfCounter;
1418+
14111419
return node;
1420+
}
14121421
} // try
14131422
catch (const Firebird::Exception& ex)
14141423
{
@@ -1448,18 +1457,7 @@ const StmtNode* EXE_looper(thread_db* tdbb, jrd_req* request, const StmtNode* no
14481457
} // while()
14491458

14501459
if (attachment->isProfilerActive() && !request->hasInternalStatement())
1451-
{
1452-
const SINT64 currentPerfCounter = fb_utils::query_performance_counter();
1453-
1454-
if (profileNode)
1455-
{
1456-
attachment->getProfilerManager(tdbb)->afterPsqlLineColumn(request,
1457-
profileNode->line, profileNode->column,
1458-
currentPerfCounter - lastPerfCounter);
1459-
}
1460-
1461-
request->req_profiler_time += currentPerfCounter - initialPerfCounter;
1462-
}
1460+
request->req_profiler_time += profilerCallAfterPsqlLineColumn() - initialPerfCounter;
14631461

14641462
request->adjustCallerStats();
14651463

0 commit comments

Comments
 (0)