Skip to content

Commit 62a2a15

Browse files
authored
Per pagespace I/O statistics and new trace API interfaces to allow extendable statistics (#8808)
* Add support of grouping page-level I/O counters per pagespace * Add support for per-pagespace I/O statistics. Deprecate non-extendable PerformanceInfo struct in favor of the new PerformanceCounters/PerformanceStats interfaces. Adjust the trace implementation to the new API. * Better names for interface methods. Add the basic docs. Get rid of the separate global counters. Misc renaming. * Add the docs weirdly escaped from the last commit * Follow Dimitry Sibiryakov's suggestion to unify get*Counters methods. * Rename the method
1 parent e878785 commit 62a2a15

File tree

17 files changed

+1783
-534
lines changed

17 files changed

+1783
-534
lines changed

doc/Using_OO_API.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,3 +2101,44 @@ struct FbVarChar
21012101

21022102
This document is currently missing 2 types of plugins – ExternalEngine and Trace. Information about them will be made
21032103
available in next release of it.
2104+
2105+
# Trace plugin
2106+
2107+
_TODO_
2108+
2109+
# Trace objects
2110+
2111+
_TODO_
2112+
2113+
# Trace performance statistics
2114+
2115+
Trace plugin may retrieve various performance statistics available using the `getPerfStats()` method of the trace object, which returns a pointer to the `IPerformanceStats` interface.
2116+
2117+
```cpp
2118+
IPerformanceStats* stats = statement->getPerfStats();
2119+
```
2120+
2121+
The returned pointer may be `nullptr` if the corresponding trace object is not in the terminate state yet (i.e. still active / being executed).
2122+
2123+
<a name="PerformanceStats"></a> PerformanceStats interface:
2124+
2125+
- ISC_UINT64 getElapsedTime() - returns the elapsed time, in milliseconds
2126+
- ISC_UINT64 getFetchedRecords() - returns number of records fetched during execution
2127+
- IPerformanceCounters* getCounters(unsigned group) - returns the requested performance counters group
2128+
2129+
The following groups of performance counters are currently supported:
2130+
2131+
- COUNTER_GROUP_PAGES - per-pagespace counters
2132+
- COUNTER_GROUP_TABLES - per-table counters
2133+
2134+
If `getCounters()` is called with a counter group not supported by the implementation, `nullptr` is returned.
2135+
2136+
<a name="PerformanceCounters"></a> PerformanceCounters interface:
2137+
2138+
- unsigned getObjectCount() - returns number of objects (e.g. tables) containing non-zero performance counters
2139+
- unsigned getMaxCounterIndex() - returns maximum index number of the performance counters supported by the implementation (it's the same for all objects of the same group)
2140+
- unsigned getObjectId(unsigned index) - returns ID of the specified object
2141+
- const char* getObjectName(unsigned index) - returns name of the specified object
2142+
- const ISC_INT64* getObjectCounters(unsigned index) - returns pointer to the vector of performance counters (containing getMaxCounterIndex() + 1 elements) of the specified object
2143+
2144+
The returned pointer to the vector (as well as the whole instance of `PerformanceStats`) is valid until the object used to obtain the statistics (using the `getPerfStats()` method) is destroyed.

src/include/firebird/FirebirdInterface.idl

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,9 @@ interface TraceTransaction : Versioned
13641364
version: // 3.0.4 -> 3.0.5
13651365
int64 getInitialID();
13661366
int64 getPreviousID();
1367+
1368+
version: // 5.0 -> 6.0
1369+
PerformanceStats getPerfStats();
13671370
}
13681371

13691372
interface TraceParams : Versioned
@@ -1379,6 +1382,9 @@ interface TraceStatement : Versioned
13791382
{
13801383
int64 getStmtID();
13811384
PerformanceInfo* getPerf();
1385+
1386+
version: // 5.0 -> 6.0
1387+
PerformanceStats getPerfStats();
13821388
}
13831389

13841390
interface TraceSQLStatement : TraceStatement
@@ -1421,6 +1427,9 @@ version: // 4.0 -> 5.0
14211427
int64 getStmtID();
14221428
const string getPlan();
14231429
const string getExplainedPlan();
1430+
1431+
version: // 5.0 -> 6.0
1432+
PerformanceStats getPerfStats();
14241433
}
14251434

14261435
interface TraceFunction : Versioned
@@ -1434,6 +1443,9 @@ version: // 4.0 -> 5.0
14341443
int64 getStmtID();
14351444
const string getPlan();
14361445
const string getExplainedPlan();
1446+
1447+
version: // 5.0 -> 6.0
1448+
PerformanceStats getPerfStats();
14371449
}
14381450

14391451
interface TraceTrigger : Versioned
@@ -1456,6 +1468,9 @@ version: // 4.0 -> 5.0
14561468
int64 getStmtID();
14571469
const string getPlan();
14581470
const string getExplainedPlan();
1471+
1472+
version: // 5.0 -> 6.0
1473+
PerformanceStats getPerfStats();
14591474
}
14601475

14611476
interface TraceServiceConnection : TraceConnection
@@ -1480,6 +1495,9 @@ interface TraceSweepInfo : Versioned
14801495
int64 getOAT();
14811496
int64 getNext();
14821497
PerformanceInfo* getPerf();
1498+
1499+
version: // 5.0 -> 6.0
1500+
PerformanceStats getPerfStats();
14831501
}
14841502

14851503
interface TraceLogWriter : ReferenceCounted
@@ -1876,3 +1894,50 @@ interface ProfilerStats : Versioned
18761894
{
18771895
uint64 getElapsedTicks();
18781896
}
1897+
1898+
// Extendable replacement for struct PerformanceInfo
1899+
1900+
interface PerformanceCounters : Versioned
1901+
{
1902+
// Page-level performance counters (grouped per tablespace)
1903+
const uint PAGE_FETCHES = 0;
1904+
const uint PAGE_READS = 1;
1905+
const uint PAGE_MARKS = 2;
1906+
const uint PAGE_WRITES = 3;
1907+
1908+
// Record-level performance counters (grouped per table)
1909+
const uint RECORD_SEQ_READS = 0;
1910+
const uint RECORD_IDX_READS = 1;
1911+
const uint RECORD_UPDATES = 2;
1912+
const uint RECORD_INSERTS = 3;
1913+
const uint RECORD_DELETES = 4;
1914+
const uint RECORD_BACKOUTS = 5;
1915+
const uint RECORD_PURGES = 6;
1916+
const uint RECORD_EXPUNGES = 7;
1917+
const uint RECORD_LOCKS = 8;
1918+
const uint RECORD_WAITS = 9;
1919+
const uint RECORD_CONFLICTS = 10;
1920+
const uint RECORD_BACK_READS = 11;
1921+
const uint RECORD_FRAGMENT_READS = 12;
1922+
const uint RECORD_RPT_READS = 13;
1923+
const uint RECORD_IMGC = 14;
1924+
1925+
uint getObjectCount();
1926+
uint getMaxCounterIndex();
1927+
1928+
uint getObjectId(uint index);
1929+
const string getObjectName(uint index);
1930+
const int64* getObjectCounters(uint index);
1931+
}
1932+
1933+
interface PerformanceStats : Versioned
1934+
{
1935+
const uint COUNTER_GROUP_PAGES = 0;
1936+
const uint COUNTER_GROUP_TABLES = 1;
1937+
1938+
uint64 getElapsedTime(); // in milliseconds
1939+
uint64 getFetchedRecords();
1940+
1941+
PerformanceCounters getCounters(uint group);
1942+
}
1943+

0 commit comments

Comments
 (0)