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

Commit99922c1

Browse files
committed
Implement support for running benchmarks with perf
1 parent37e3134 commit99922c1

6 files changed

+55
-4
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ 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:
146150
build_args+= ['--build-arg',
147151
(f'PG_VERSION={instance.get("pg_version")}')]

‎run-benchmarks.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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