Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49fb6e4

Browse files
authored
Merge pull request#5 from alexanderlaw/main
Implement support for running benchmarks with perf
2 parents6591bf3 +99922c1 commit49fb6e4

6 files changed

+66
-15
lines changed

‎Dockerfile-pgapt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM ubuntu
2+
ARG FEATURES
23
ARG PG_VERSION
34
ARG PHASE1_ACTION
45
ARG PHASE2_ACTION
@@ -19,6 +20,8 @@ RUN p=$EXTRA_OS_PACKAGES; p="${p%\"}";p="${p#\"}"; \
1920
git gcc make libreadline-dev zlib1g-dev libicu-dev bison flex gettext \
2021
openjdk-17-jdk maven sysbench
2122

23+
RUN if (echo "$FEATURES" | grep -Eq "\bperf\b"); then apt install -y linux-tools-common linux-tools-`uname -r`; fi
24+
2225
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
2326
ENV LANG en_US.UTF-8
2427
ENV LC_ALL en_US.UTF-8
@@ -76,7 +79,12 @@ printf "\n"\
7679
"host all all 0.0.0.0/0 md5\n"\
7780
"host all all ::1/128 trust\n" >> /etc/postgresql/$PG_VERSION/main/pg_hba.conf
7881

79-
RUN echo "/usr/lib/postgresql/$PG_VERSION/bin/postgres -D /var/lib/postgresql/$PG_VERSION/main -c config_file=/etc/postgresql/$PG_VERSION/main/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain
82+
RUN if (echo "$FEATURES" | grep -Eq "\bperf\b"); then \
83+
echo "perf record -o /home/postgres/results/perf.data --call-graph dwarf -- /usr/lib/postgresql/$PG_VERSION/bin/postgres -D /var/lib/postgresql/$PG_VERSION/main -c config_file=/etc/postgresql/$PG_VERSION/main/postgresql.conf >/home/postgres/results/perf.log 2>&1; sleep inf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain; \
84+
echo "/usr/lib/postgresql/$PG_VERSION/bin/pg_ctl -w -D /var/lib/postgresql/$PG_VERSION/main stop" >/usr/bin/pg_ctl_stop && chmod a+x /usr/bin/pg_ctl_stop; \
85+
else \
86+
echo "/usr/lib/postgresql/$PG_VERSION/bin/postgres -D /var/lib/postgresql/$PG_VERSION/main -c config_file=/etc/postgresql/$PG_VERSION/main/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain; \
87+
fi
8088

8189
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-$version`` package when it was ``apt installed``
8290
USER postgres

‎Dockerfile-proapt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM ubuntu
2+
ARG FEATURES
23
ARG PG_VERSION
34
ARG PHASE1_ACTION
45
ARG PHASE2_ACTION
@@ -21,6 +22,8 @@ RUN p=$EXTRA_OS_PACKAGES; p="${p%\"}";p="${p#\"}"; \
2122
git gcc make libreadline-dev zlib1g-dev libicu-dev bison flex gettext \
2223
openjdk-17-jdk maven sysbench
2324

25+
RUN if (echo "$FEATURES" | grep -Eq "\bperf\b"); then apt install -y linux-tools-common linux-tools-`uname -r`; fi
26+
2427
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
2528
ENV LANG en_US.UTF-8
2629
ENV LC_ALL en_US.UTF-8
@@ -81,7 +84,12 @@ printf "\n"\
8184
"host all all 0.0.0.0/0 md5\n"\
8285
"host all all ::1/128 trust\n" >> /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/pg_hba.conf
8386

84-
RUN echo "/opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/postgres -D /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data -c config_file=/var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain
87+
RUN if (echo "$FEATURES" | grep -Eq "\bperf\b"); then \
88+
echo "perf record -o /home/postgres/results/perf.data --call-graph dwarf -- /opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/postgres -D /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data -c config_file=/var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf >/home/postgres/results/perf.log 2>&1; sleep inf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain; \
89+
echo "/opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/pg_ctl -w -D /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data stop" >/usr/bin/pg_ctl_stop && chmod a+x /usr/bin/pg_ctl_stop; \
90+
else \
91+
echo "/opt/pgpro/$PGPRO_EDN-$PG_VERSION/bin/postgres -D /var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data -c config_file=/var/lib/pgpro/$PGPRO_EDN-$PG_VERSION/data/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain; \
92+
fi
8593

8694
# Run the rest of the commands as the ``postgres`` user created by the ``postgres*-$version`` package when it was ``apt installed``
8795
USER postgres

‎Dockerfile-src

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM ubuntu
2+
ARG FEATURES
23
ARG PG_VERSION
34
ARG PHASE1_ACTION
45
ARG PHASE2_ACTION
@@ -20,6 +21,8 @@ RUN p=$EXTRA_OS_PACKAGES; p="${p%\"}";p="${p#\"}"; \
2021
git gcc make libreadline-dev zlib1g-dev libicu-dev bison flex gettext \
2122
openjdk-17-jdk maven sysbench
2223

24+
RUN if (echo "$FEATURES" | grep -Eq "\bperf\b"); then apt install -y linux-tools-common linux-tools-`uname -r`; fi
25+
2326
RUN locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
2427
ENV LANG en_US.UTF-8
2528
ENV LC_ALL en_US.UTF-8
@@ -58,7 +61,12 @@ RUN cd /home/postgres/src/postgres && make -s install && \
5861

5962
ENV PATH "$PATH:/usr/local/pgsql/bin"
6063

61-
RUN echo "/usr/local/pgsql/bin/postgres -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain
64+
RUN if (echo "$FEATURES" | grep -Eq "\bperf\b"); then \
65+
echo "perf record -o /home/postgres/results/perf.data --call-graph dwarf -- /usr/local/pgsql/bin/postgres -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf >/home/postgres/results/perf.log 2>&1; sleep inf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain; \
66+
echo "/usr/local/pgsql/bin/pg_ctl -w -D /var/lib/postgresql/main stop" >/usr/bin/pg_ctl_stop && chmod a+x /usr/bin/pg_ctl_stop; \
67+
else \
68+
echo "/usr/local/pgsql/bin/postgres -D /var/lib/postgresql/main -c config_file=/var/lib/postgresql/main/postgresql.conf" >/usr/bin/pgmain && chmod a+x /usr/bin/pgmain; \
69+
fi
6270

6371
COPY ./$PHASE2_ACTION /bin/
6472
RUN $PHASE2_ACTION

‎config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<osversion="23.04" />
3131
</instance>
3232
<xi:includehref="private_instances.xml" />
33+
<instanceid="pg-src-master-perf"disabled="true"type="src"features="perf"git_branch="master" />
3334
<instanceid="pg-src-15"type="src"pg_version="15devel"git_branch="REL_15_STABLE" />
3435
<instanceid="pg-src-master"type="src"pg_version="16devel"git_branch="master" />
3536
</pg_instances>

‎prepare-instances.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ def get_repo_url(instance):
142142
encoding='UTF-8')asdockerfile:
143143
dockerfile.write(df_contents)
144144

145+
ifinstance.get('features')isnotNone:
146+
build_args+= ["--build-arg",
147+
(f'FEATURES={instance.get("features")}')]
148+
145149
ifinstance.get('pg_version')isnotNone:
146-
build_args+= ['--build-arg', ('PG_VERSION='+
147-
instance.get('pg_version'))]
150+
build_args+= ['--build-arg',
151+
(f'PG_VERSION={instance.get("pg_version")}')]
148152
ifinstance.get('pgpro_edition')isnotNone:
149-
build_args+= ['--build-arg', ('PGPRO_EDN='+
150-
instance.get('pgpro_edition'))]
153+
build_args+= ['--build-arg',
154+
(f'PGPRO_EDN={instance.get("pgpro_edition")}')]
151155
pg_params=''
152156
forparamininstance.findall('config/pg_param'):
153157
pg_params+=f"{param.get('name')} = '{param.get('value')}'\\n"
@@ -157,15 +161,15 @@ def get_repo_url(instance):
157161

158162
repo_url=get_repo_url(instance)
159163
ifrepo_urlisnotNone:
160-
build_args+= ['--build-arg', ('REPOSITORY='+repo_url)]
164+
build_args+= ['--build-arg', (f'REPOSITORY={repo_url}')]
161165

162166
extra=instance.find('extra')
163167
ifextraisnotNone:
164168
ifextra.find('source')isnotNoneand \
165169
extra.find('source').get('type')=='git':
166170
extra_git_url=extra.find('source').get('url')
167-
build_args+= ['--build-arg', ('EXTRA_SRC_GIT='+
168-
extra_git_url)]
171+
build_args+= ['--build-arg',
172+
(f'EXTRA_SRC_GIT={extra_git_url}')]
169173
pg_modules=''
170174
forpgminextra.findall('pg_module'):
171175
pg_modules+= (','ifpg_moduleselse'')+pgm.get('name')
@@ -182,8 +186,8 @@ def get_repo_url(instance):
182186
phase2_action=instance.find('os').get('phase2_action')
183187
ifinstance.find('os').get('extra_packages')isnotNone:
184188
extra_os_packages=instance.find('os').get('extra_packages')
185-
build_args+= ['--build-arg', ('PHASE1_ACTION='+phase1_action)]
186-
build_args+= ['--build-arg', ('PHASE2_ACTION='+phase2_action)]
189+
build_args+= ['--build-arg', (f'PHASE1_ACTION={phase1_action}')]
190+
build_args+= ['--build-arg', (f'PHASE2_ACTION={phase2_action}')]
187191
build_args+= ['--build-arg',
188192
(f'EXTRA_OS_PACKAGES="{extra_os_packages}"')]
189193

‎run-benchmarks.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def main(configfile, instances, benchmarks, resultsfile, resultsdir):
106106
insts= {}
107107
ifnotinstances:
108108
forinstinconfig.findall('./pg_instances//instance'):
109+
ifinst.get('disabled')=='true':
110+
continue
109111
insts[inst.get('id')]=inst
110112
else:
111113
inst_cnts= {}
@@ -155,8 +157,6 @@ def main(configfile, instances, benchmarks, resultsfile, resultsdir):
155157
bmbench.set('id',bench_id)
156158
forinstance_uid,instanceininsts.items():
157159
instance_id=instance.get('id')
158-
ifinstance.get('disabled')=='true':
159-
continue
160160

161161
ifre.match(r'^[\./]',instance_id):
162162
raiseException(f'Invalid image id:{instance_id}')
@@ -188,7 +188,7 @@ def main(configfile, instances, benchmarks, resultsfile, resultsdir):
188188
f'-v{os.getcwd()}/resources:/home/postgres/resources '
189189
f'-v{os.getcwd()}/scripts:/home/postgres/scripts '
190190
f'-v{resultdir}:/home/postgres/results '
191-
f'--tty --cap-add=SYS_PTRACE '
191+
f'--tty --cap-add=SYS_PTRACE--cap-add=SYS_ADMIN'
192192
f'--shm-size=2g{envvars}{instance_id}',
193193
shell=True,check=True,stdout=subprocess.PIPE)
194194
container_id=res.stdout.decode('utf-8').strip()
@@ -247,6 +247,28 @@ def main(configfile, instances, benchmarks, resultsfile, resultsdir):
247247
print(output)
248248
raiseException('Benchmark execution failed! (For details '
249249
'see benchmark-results/.)')
250+
251+
instance_features=instance.get('features')
252+
ifre.match(r'\bperf\b',instance_features):
253+
res=run(f'docker exec -t{container_id} bash -c '
254+
f'pg_ctl_stop',
255+
shell=True,check=False,stdout=subprocess.PIPE)
256+
ifres.returncode!=0:
257+
print(res.stdout.decode('utf-8'))
258+
raiseException('Could not stop server.')
259+
sleep(10)
260+
res=run(f'docker exec -t{container_id} bash -c "'
261+
f'perf report --stdio -i'
262+
f' /home/postgres/results/perf.data'
263+
f' >/home/postgres/results/perf.out 2>&1; '
264+
f'perf script -i'
265+
f' /home/postgres/results/perf.data'
266+
f' >/home/postgres/results/perf.script 2>&1"',
267+
shell=True,check=False,stdout=subprocess.PIPE)
268+
ifres.returncode!=0:
269+
print(res.stdout.decode('utf-8'))
270+
raiseException('Could not get perf report.')
271+
250272
formetricinbench.findall('./results/metric'):
251273
mid=metric.get('id')
252274
mre=metric.get('regexp')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp