Skip to content

Commit 3c43eaf

Browse files
committed
Misc code for distributing oltpcore/mtitcore processes
1 parent 87b7e95 commit 3c43eaf

File tree

11 files changed

+229
-49
lines changed

11 files changed

+229
-49
lines changed

bin/mtitcore

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
# Changes
1212
#
13-
# bengsig 10-may-2023 Creation
13+
# bengsig 9-nov-2023 - support multiple application servers
14+
# bengsig 10-may-2023 - Creation
1415

1516
# If stdin is not a tty
1617
# show how we were called
@@ -156,7 +157,7 @@ fi
156157
eval `rwloadsim -q -i proccount:=$procs -i runperiod:=$runperiod parameters2shell.rwl`
157158

158159
# verify that it compiles
159-
rwloadsim -u -v $extra_args -e -- '-x $mute:141' $runfile || exit $?
160+
rwloadsim -u -v $extra_args -e '-x $mute:141' $runfile || exit $?
160161

161162
if test $mtitxc = yes
162163
then
@@ -189,7 +190,7 @@ then
189190
rwloadsim -u -v -c 15 -sss -P $prepfile -k $key -K "$komment" -q \
190191
--fulltitle="$komment" \
191192
-i runperiod:=$runperiod -i proccount:=$procs prepare.rwl
192-
mute59='-x$mute:59'
193+
mute59='--mute=59'
193194
else
194195
rwloadsim -u -v -c $rampup -sss -P $prepfile -k $key -K "$komment" -q \
195196
--fulltitle="$komment" \
@@ -227,7 +228,6 @@ then
227228
echo $! >> $killfile
228229
fi
229230

230-
markerfile='string(1000)xc_marker_file:="'$resultsdir/$subdir/$runnumber/markers.txt'";'
231231
quiet=''
232232

233233
# Start sys gather
@@ -239,17 +239,20 @@ then
239239
echo $awrpid >> $killfile
240240
fi
241241

242+
prepvalue=`cat $prepfile`
242243
# show countdown to user
243244
echo -n '**** remaining:'
244245
# Start the real workers
245246
while test $procnumber -le $procs
246247
do
247248
sleep $script_ramp
248249
echo -n " "`expr $procs - $procnumber`
249-
rwloadsim $mute59 -u -r -i procnumber:=$procnumber \
250+
eval $(rwloadsim -q -i proccount:=$procs -i runperiod:=$runperiod rwlcall.rwl -i procnumber:=$procnumber)
251+
252+
$rwlcall $rwlcallargs $mute59 -u -r -i procnumber:=$procnumber \
250253
--flush-stop=$runperiod --flush-every=2 -v -i runperiod:=$runperiod \
251-
--procno $procnumber \
252-
-W -i doawr:=$doawr -x "$markerfile" $mtitsetxc $extra_args -i proccount:=$procs -R $prepfile $quiet $runfile &
254+
--procno $procnumber --markerfile=$resultsdir/$subdir/$runnumber/markers.txt \
255+
-W -i doawr:=$doawr $mtitsetxc $extra_args -i proccount:=$procs -M $prepvalue $quiet $runfile &
253256
quiet='-q' # only messages from first
254257
procnumber=`expr $procnumber + 1`
255258
if test x$killfile != x

bin/oltpcore

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# Changes
1313
#
14+
# bengsig 9-nov-2023 - support multiple application servers
1415
# bengsig 2-nov-2023 - Add extra_args plots, etc
1516
# bengsig 17-oct-2023 - Add extra_args to prepare
1617
# bengsig 29-sep-2023 - No ash if no awr
@@ -179,7 +180,7 @@ fi
179180
eval `rwloadsim -q $extra_args -i proccount:=$procs -i runperiod:=$runperiod parameters2shell.rwl`
180181

181182
# verify that it compiles
182-
rwloadsim -q -u -v $extra_args -e -- '-x $mute:141' $runfile || exit $?
183+
rwloadsim -q -u -v $extra_args -e '-x $mute:141' $runfile || exit $?
183184

184185
if test $oltpxc = yes
185186
then
@@ -215,7 +216,7 @@ then
215216
rwloadsim $extra_args -u -v -c 15 -sss -P $prepfile -k $key -K "$komment" -q \
216217
--fulltitle="$komment" \
217218
-i runperiod:=$runperiod -i proccount:=$procs prepare.rwl
218-
mute59='-x$mute:59'
219+
mute59='--mute=59'
219220
else
220221
rwloadsim $extra_args -u -v -c $rampup -sss -P $prepfile -k $key -K "$komment" -q \
221222
--fulltitle="$komment" \
@@ -255,7 +256,6 @@ then
255256
echo $! >> $killfile
256257
fi
257258

258-
markerfile='string(1000)xc_marker_file:="'$resultsdir/$subdir/$runnumber/markers.txt'";'
259259
quiet=''
260260

261261
# Start sys gather
@@ -273,16 +273,21 @@ then
273273
rwloadsim -u -q -i simulatebatch:=$simulatebatch -i runperiod:=$runperiod -R $prepfile runtrunc.rwl &
274274
fi
275275

276+
prepvalue=`cat $prepfile`
277+
276278
# show countdown to user
277279
echo -n '**** remaining:'
278280
# Start the real workers
279281
while test $procnumber -le $procs
280282
do
281283
sleep $script_ramp
282284
echo -n " "`expr $procs - $procnumber`
283-
rwloadsim $mute59 -u -r -i simulatebatch:=$simulatebatch -i procnumber:=$procnumber \
285+
# get the actual call to execute in background
286+
eval $(rwloadsim -q -i proccount:=$procs -i runperiod:=$runperiod rwlcall.rwl -i procnumber:=$procnumber)
287+
# by default, rwlcall=rwloadsim and rwlcallargs is empty
288+
$rwlcall $rwlcallargs $mute59 -u -r -i simulatebatch:=$simulatebatch -i procnumber:=$procnumber \
284289
--flush-stop=$runperiod --flush-every=2 -v -i runperiod:=$runperiod \
285-
-W -i xc_run_dedicated:=$xc_run_dedicated -i doawr:=$doawr -x $markerfile $oltpsetxc $extra_args -i proccount:=$procs -R $prepfile $quiet $runfile &
290+
-W -i xc_run_dedicated:=$xc_run_dedicated -i doawr:=$doawr --markerfile=$resultsdir/$subdir/$runnumber/markers.txt $oltpsetxc $extra_args -i proccount:=$procs -M $prepvalue $quiet $runfile &
286291
quiet='-q' # only messages from first
287292
procnumber=`expr $procnumber + 1`
288293
if test x$killfile != x

man/man2rwl/oltpsetup.2rwl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,43 @@ To verify you can connect to a repository, run \fBoltpverify -r\fR.
575575
To create all schemas, run \fBoltpcreate\fR; to drop all schemas expect the repository, run \fBoltpdrop\fR.
576576
.P
577577
To verify schemas are properly created, run \fBoltpverify -u\fR.
578+
.SH "REMOTE EXECUTION"
579+
Normally, all the background processes started by e.g. \fBoltprun\fR are started on the same single host.
580+
If that host is running out of CPU resources, you can prepare distribution of the processes to
581+
multiple servers.
582+
This is done by declaring a procedure named \fBrwlcall\fR taking a single integer argument.
583+
The argument provided will be a process number in the range from 2 until the value of the -n argument
584+
to \fBoltprun\fR.
585+
The process with process number 1 will always be started on the same host where \fBoltprun\fR is executed.
586+
The procedure must output exactly two lines that are setting sh variables named \fBrwlcall\fR
587+
and \fBrwlcallargs\fR.
588+
Those two will be used to start the actual background process.
589+
A sample declaration that will distribute the workload to three different hosts is the following:
590+
.P
591+
.nf
592+
procedure rwlcall(integer prno)
593+
is
594+
printline "rwlcall='ssh'";
595+
printf "rwlcallargs='-n -tt appsrv%02d.domain.tld /path/to/remoterwloadsim.bash'\\n"
596+
, prno%3+1;
597+
end rwlcall;
598+
.fi
599+
.P
600+
A template for the bash script \fBremoterwloadsim.bash\fR is found in the oltp directory of your
601+
rwloadsim distribution.
602+
It should be copied to all remote systems and modifed according to the instructions in
603+
the file, setting the proper environment to execute rwloadsim remotely.
604+
Note that remote execution is an experimental feature that may change in a later release.
605+
.P
606+
If the procedure is not declared, the following will be used
607+
.P
608+
.nf
609+
printline "rwlcall='rwloadsim'";
610+
printline "rwlcallargs=''";
611+
.fi
612+
.P
613+
implying rwloadsim will be started locally.
614+
This is always used for process number 1, as it must run locally.
578615
.SH "UNDOCUMENTED PARAMETERS"
579616
There are some extra parameters, that you can set in either your \fBkey.rwl\fR file or using -i or -d on the
580617
oltprun command line.

oltp/mtitrun.rwl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0
33
# as shown at https://oss.oracle.com/licenses/upl/
44

5+
# bengsig 9-nov-2023 - support multiple application servers
56
# bengsig 17-jul-2023 - Call mtit_initialize in each thread
67
# bengsig 23-apr-2023 - Creation
78

@@ -18,6 +19,8 @@ $include:"ovid2.rwl"
1819
$include:"mtit_user.rwl"
1920
$include:"mtit_declarations.rwl"
2021

22+
string(1000) markerfile; $useroption:markerfile
23+
# note that markerfile is only used by xc_implementation
2124
$if mtit_xc $then
2225
$include:"xc_implementation.rwl"
2326

oltp/parameters.rwl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Licensed under the Universal Permissive License v 1.0
33
# as shown at https://oss.oracle.com/licenses/upl/
44

5+
# bengsig 9-nov-2023 - support multiple application servers
6+
# bengsig 6-nov-2023 - burst function
57
# bengsig 1-nov-2023 - burst can be repeated
68
# bengsig 17-oct-2023 - output resolution
79
# bengsig 3-oct-2023 - parsefailure
@@ -671,6 +673,10 @@ if show_changed_values then
671673
end if;
672674
printline "aw_cols_256MB_doublings=" aw_cols_256MB_doublings;
673675
printline "aw_cols_skew=" aw_cols_skew;
676+
$if defined(rwlcall) $then
677+
printline "processes will be running via user defined ssh with this as an example:";
678+
rwlcall(2);
679+
$endif
674680
end if;
675681

676682
string svgmouse ;

oltp/remoterwloadsim.bash

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# RWP*Load Simulator - Call rwloadsime remotely
4+
#
5+
# Copyright (c) 2021 Oracle Corporation
6+
# Licensed under the Universal Permissive License v 1.0
7+
# as shown at https://oss.oracle.com/licenses/upl/
8+
#
9+
# History
10+
#
11+
# bengsig 8-nov-2023 - Creation
12+
#
13+
# This file is a sample of how to implement spreading of
14+
# oltp worker processes remotely. It will be called using
15+
# ssh with an unknown environment that can depend on sevaral
16+
# factors, so ALL environment variables below must be set
17+
# properly
18+
19+
# You need to copy this file to all your remote application
20+
# servers and provide the full name to it in your implementation
21+
# of the rwlcall function
22+
#
23+
# Note that things will be much easier if the home directory
24+
# of the account you are using and the rwloadsim distribution
25+
# are shared (e.g. via NFS) to all application servers.
26+
27+
# Set the RWLOADSIM_PATH such that it includes the following two
28+
# directories on the remote system:
29+
# the directory where a copy of {key}.rwl is found
30+
# the oltp directory of your rwloadsim distribution
31+
# Effectively, this is similar to your normal {key}.env file
32+
export RWLOADSIM_PATH=/path/to/keydirectory:/path/to/rwloadsim/oltp
33+
export RWLOLTP_NAME=key # put your project name here
34+
# Set the following two such that it provides access to rwloadsim, sqlplus, etc:
35+
export LD_LIBRARY_PATH=/path/to/instantclient
36+
PATH=/path/to/rwloadsim/bin:/bin:/usr/bin:/usr/local/bin:/path/to/instantclient
37+
# Change to the directory where {key}.rwl is found
38+
cd /path/to/keydirectory
39+
40+
# finally do the actual call to rwloadsim
41+
rwloadsim "$@"
42+

oltp/run.rwl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0
33
# as shown at https://oss.oracle.com/licenses/upl/
44

5+
# bengsig 6-nov-2023 - burst function
56
# bengsig 1-nov-2023 - burst can be repeated
67
# bengsig 11-sep-2023 - max_sessionwait
78
# bengsig 31-jul-2023 - Add experimental 24h simulation
@@ -16,6 +17,7 @@
1617

1718
integer xc_run_dedicated := 0;
1819

20+
1921
$statistics:all
2022

2123
$include:"parameters.rwl"
@@ -34,6 +36,8 @@ $include:"oe_handle_products.rwl"
3436
$include:"aw_declarations.rwl"
3537
$include:"oe_long_session.rwl"
3638

39+
string(1000) markerfile; $useroption:markerfile
40+
# note that markerfile is only used by xc_implementation
3741
$if xc_enabled $then
3842
$include:"xc_implementation.rwl"
3943
$endif

oltp/rwlcall.rwl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2021 Oracle Corporation
2+
# Licensed under the Universal Permissive License v 1.0
3+
# as shown at https://oss.oracle.com/licenses/upl/
4+
5+
# bengsig 7-nov-2023 - Creation
6+
7+
#
8+
# If the rwlcall function exists, call it with the process number
9+
# as argument, unless process number is 1. Process number 1
10+
# must always executed on the host where you run oltpcore.
11+
#
12+
# The output from this will be used in eval $(rwloadsim rwlcall.rwl)
13+
# in oltpcore (and mtitcore) and it should therefore output
14+
# nothing more than sh commands to set the two variables rwlcall
15+
# and rwlcallargs.
16+
#
17+
# The default is to print this:
18+
#
19+
# rwlcall=rwloadsim
20+
# rwlcallargs=''
21+
#
22+
# which will imply the real worker threads will be executed on the host
23+
# calling oltpcore simply using rwloadsim
24+
#
25+
# The function provided by the user is supposed to print something like:
26+
# rwlcall=ssh
27+
# rwlcallargs='-n -tt hostname /path/to/somewhere/remoterwloadsim.bash'
28+
# where the bash script is a modified version of the one found in the oltp
29+
# directory of your rwloadsim distribution.
30+
#
31+
$include:"parameters.rwl"
32+
33+
$if defined(rwlcall) and procnumber > 1 $then
34+
rwlcall(procnumber);
35+
$else
36+
printline "rwlcall='rwloadsim'";
37+
printline "rwlcallargs=''";
38+
$endif
39+

oltp/xc_implementation.rwl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
# History
99
#
10+
# bengsig 9-nov-2023 - support multiple application servers
1011
# bengsig 3-oct-2023 - parsefailure
1112
# bengsig 1-aug-2023 - Add oltpxcset markers from oltpxcrun
1213
# bengsig 17-jul-2023 - Show affinity properly
@@ -19,18 +20,26 @@ $niceabort:on
1920
$queueeverytiming:on
2021
$mute:206
2122

22-
string(1000) xc_marker_file := "";
23+
$if !defined(markerfile) $then
24+
# This is a bit of a hack: We need to have markerfile declared in run.rwl
25+
# such that it can be associated with a --markerfile useroption, as otherwise
26+
# oltpcore cannot provide a value to it. It is really only used if xc_read
27+
# is called with its argument repchg set to 1 (true) in which case the
28+
# changes picked up by xc_read are writting to stdout and markerfile.
29+
# And xc_read is only called with repchg true when procnumber=1 in oltpcore
30+
string(1000) markerfile := "";
31+
$endif
2332

24-
if xc_marker_file != "" then
25-
system "rm -f " xc_marker_file;
33+
if markerfile != "" then
34+
system "rm -f " markerfile;
2635
end;
2736

2837
procedure xc_marker(string txt)
29-
if xc_marker_file = "" then
38+
if markerfile = "" then
3039
return;
3140
end;
3241

33-
file mf >>= xc_marker_file;
42+
file mf >>= markerfile;
3443
fprintf mf, "%.1f %s\n", runseconds(), txt;
3544
mf := null;
3645
end;

src/rwl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*
1414
* History
1515
*
16+
* bengsig 9-nov-2023 - Increase RWL_MAX_VAR
1617
* bengsig 3-oct-2023 - Now development for 3.1.1
1718
* bengsig 2-oct-2023 - Releasing 3.1.0
1819
* bengsig 22-sep-2023 - ampersand fixes
@@ -1281,7 +1282,7 @@ struct rwl_identifier
12811282
rwlmutexrel(xev,loc,(xev)->rwm->mxq->evar[(vnum)].var_mutex); \
12821283
} while (0)
12831284

1284-
#define RWL_MAX_VAR 500 /* default number of variables */
1285+
#define RWL_MAX_VAR 600 /* default number of variables */
12851286
// This is an array that we do not increase in runtime
12861287
// Doing so would be major change, but user can specify -I
12871288
// to set a larger size

0 commit comments

Comments
 (0)