Project

General

Profile

roundtrips.p

Artur Școlnic, 08/26/2026 07:32 AM

Download (5.96 KB)

 
1
/*------------------------------------------------------------------------
2
   File        : roundtrips.p
3
   Purpose     : Count SERVER ROUND TRIPS for retrieval and reposition, by
4
                 sampling the _ActServer VST before and after each operation.
5
   Notes       : Single session on purpose - no harness, no writer.  With one
6
                 client connected the _ActServer deltas are attributable, which
7
                 they would not be if a second session were generating traffic.
8

    
9
                 The observation logs used everywhere else show record CONTENT,
10
                 so they can reveal a stale window but never a round trip.  This
11
                 probe answers the questions content cannot:
12

    
13
                   - does REPOSITION walk to its target (delta scales with
14
                     distance) or seek to it (delta constant)?
15
                   - does INDEXED-REPOSITION differ?
16
                   - is the stored metaschema (_File) fetched from the server at
17
                     all, or served from the client's schema cache?  Zero messages
18
                     means the prefetch question does not apply to it.
19
                   - are VSTs (_Connect) fetched per row?
20
                   - independent cross-check of the theme 9 result: a static
21
                     query without SCROLLING should cost ~one message per row,
22
                     while FOR EACH should cost far fewer.
23

    
24
                 Reading the VST is itself a server request, so BASELINE measures
25
                 the instrument's own cost and every figure below should be read
26
                 net of it.
27
 ----------------------------------------------------------------------*/
28

    
29
define variable nRows   as integer no-undo.
30
define variable before  as int64   no-undo.
31
define variable after   as int64   no-undo.
32
define variable baseCost as int64  no-undo.
33
define variable i       as integer no-undo.
34
define variable rids    as rowid extent 120 no-undo.
35

    
36
define query qPlain     for Book.
37
define query qScroll    for Book scrolling.
38
define query qIdxRepos  for Book scrolling.
39

    
40
/* Messages RECEIVED by all server processes = requests this client made. */
41
function srvMsgs returns int64 ():
42
   define variable t as int64 no-undo.
43
   for each _ActServer no-lock:
44
      t = t + _ActServer._Server-MsgRec.
45
   end.
46
   return t.
47
end function.
48

    
49
define stream rep.
50
output stream rep to "C:\oetest\roundtrips.out".
51

    
52
procedure report:
53
   define input parameter what  as character no-undo.
54
   define input parameter delta as int64     no-undo.
55
   define input parameter rows  as integer   no-undo.
56
   put stream rep unformatted
57
       substitute("&1 msgs=&2 rows=&3 net=&4",
58
                  string(what, "x(46)"), string(delta, ">>>>>9"),
59
                  string(rows, ">>>>9"),
60
                  string(delta - baseCost, "->>>>9")) skip.
61
end procedure.
62

    
63
put stream rep unformatted "proversion=" proversion
64
    " dbparam=" dbparam(ldbname(1)) skip(1).
65

    
66
/* ---- instrument cost: two samples with nothing in between ---- */
67
before = srvMsgs().
68
after  = srvMsgs().
69
baseCost = after - before.
70
put stream rep unformatted "baseline (two consecutive VST samples) = "
71
    string(baseCost) " msgs -- subtract this from every figure" skip(1).
72

    
73
/* ---- retrieval forms ---- */
74
before = srvMsgs().
75
nRows = 0.
76
for each Book no-lock:
77
   nRows = nRows + 1.
78
end.
79
after = srvMsgs().
80
run report ("FOR EACH Book NO-LOCK", after - before, nRows).
81

    
82
before = srvMsgs().
83
nRows = 0.
84
open query qScroll for each Book no-lock.
85
get next qScroll.
86
do while available Book:
87
   nRows = nRows + 1.
88
   get next qScroll.
89
end.
90
close query qScroll.
91
after = srvMsgs().
92
run report ("static DEFINE QUERY SCROLLING + GET NEXT", after - before, nRows).
93

    
94
before = srvMsgs().
95
nRows = 0.
96
open query qPlain for each Book no-lock.
97
get next qPlain.
98
do while available Book:
99
   nRows = nRows + 1.
100
   get next qPlain.
101
end.
102
close query qPlain.
103
after = srvMsgs().
104
run report ("static DEFINE QUERY no SCROLLING + GET NEXT", after - before, nRows).
105

    
106
before = srvMsgs().
107
nRows = 0.
108
find first Book no-lock.
109
nRows = 1.
110
repeat:
111
   find next Book no-lock no-error.
112
   if not available Book then leave.
113
   nRows = nRows + 1.
114
end.
115
after = srvMsgs().
116
run report ("FIND FIRST + repeated FIND NEXT", after - before, nRows).
117

    
118
/* ---- capture rowids for the reposition probes ---- */
119
i = 0.
120
for each Book no-lock by Book.book-id:
121
   i = i + 1.
122
   if i <= extent(rids) then rids[i] = rowid(Book).
123
end.
124

    
125
/* ---- REPOSITION distance sweep, plain ---- */
126
do i = 1 to 3:
127
   define variable target as integer no-undo.
128
   target = (if i eq 1 then 2 else if i eq 2 then 50 else 100).
129

    
130
   open query qScroll for each Book no-lock.
131
   get next qScroll.
132
   before = srvMsgs().
133
   reposition qScroll to rowid rids[target] no-error.
134
   get next qScroll.
135
   after = srvMsgs().
136
   close query qScroll.
137
   run report (substitute("REPOSITION TO ROWID -> row &1", string(target)),
138
               after - before, 1).
139
end.
140

    
141
/* ---- REPOSITION distance sweep, INDEXED-REPOSITION ---- */
142
do i = 1 to 3:
143
   define variable target2 as integer no-undo.
144
   target2 = (if i eq 1 then 2 else if i eq 2 then 50 else 100).
145

    
146
   open query qIdxRepos for each Book no-lock indexed-reposition.
147
   get next qIdxRepos.
148
   before = srvMsgs().
149
   reposition qIdxRepos to rowid rids[target2] no-error.
150
   get next qIdxRepos.
151
   after = srvMsgs().
152
   close query qIdxRepos.
153
   run report (substitute("INDEXED-REPOSITION -> row &1", string(target2)),
154
               after - before, 1).
155
end.
156

    
157
/* ---- _meta: stored metaschema vs VST ---- */
158
before = srvMsgs().
159
nRows = 0.
160
for each _File no-lock:
161
   nRows = nRows + 1.
162
end.
163
after = srvMsgs().
164
run report ("FOR EACH _File NO-LOCK (stored metaschema)", after - before, nRows).
165

    
166
before = srvMsgs().
167
nRows = 0.
168
for each _Field no-lock:
169
   nRows = nRows + 1.
170
end.
171
after = srvMsgs().
172
run report ("FOR EACH _Field NO-LOCK (stored metaschema)", after - before, nRows).
173

    
174
before = srvMsgs().
175
nRows = 0.
176
for each _Connect no-lock:
177
   nRows = nRows + 1.
178
end.
179
after = srvMsgs().
180
run report ("FOR EACH _Connect NO-LOCK (VST)", after - before, nRows).
181

    
182
output stream rep close.