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

Commit60cfe25

Browse files
committed
Adjust spawn_process() to avoid unnecessary overhead processes: we can
just exec instead of creating a subprocess. This reduces process usagefrom four processes per parallel test to two. I have no idea whethera comparable optimization is possible or useful in the Windows port.
1 parent87c3129 commit60cfe25

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

‎doc/src/sgml/regress.sgml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.53 2006/07/19 02:37:00 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.54 2006/07/1917:02:59 tgl Exp $ -->
22

33
<chapter id="regress">
44
<title id="regress-title">Regression Tests</title>
@@ -96,11 +96,10 @@ gmake check
9696
<para>
9797
The parallel regression test starts quite a few processes under your
9898
user ID. Presently, the maximum concurrency is twenty parallel test
99-
scripts, which means sixty processes: there's a server process, a
100-
<application>psql</>, and usually a shell parent process for the
101-
<application>psql</> for each test script.
99+
scripts, which means forty processes: there's a server process and a
100+
<application>psql</> process for each test script.
102101
So if your system enforces a per-user limit on the number of processes,
103-
make sure this limit is at leastseventy-five or so, else you may get
102+
make sure this limit is at leastfifty or so, else you may get
104103
random-seeming failures in the parallel test. If you are not in
105104
a position to raise the limit, you can cut down the degree of parallelism
106105
by setting the <literal>MAX_CONNECTIONS</> parameter. For example,

‎src/test/regress/GNUmakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
# Portions Copyright (c) 1994, Regents of the University of California
88
#
9-
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.59 2006/07/1904:02:31 tgl Exp $
9+
# $PostgreSQL: pgsql/src/test/regress/GNUmakefile,v 1.60 2006/07/1917:02:59 tgl Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -39,7 +39,8 @@ EXTRADEFS = '-DPGBINDIR="$(bindir)"' \
3939
'-DLIBDIR="$(libdir)"'\
4040
'-DPGSHAREDIR="$(datadir)"'\
4141
'-DHOST_TUPLE="$(host_tuple)"'\
42-
'-DMAKEPROG="$(MAKE)"'
42+
'-DMAKEPROG="$(MAKE)"'\
43+
'-DSHELLPROG="$(SHELL)"'
4344

4445
##
4546
## Prepare for tests

‎src/test/regress/pg_regress.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.4 2006/07/1916:23:17 tgl Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.5 2006/07/1917:02:59 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -60,6 +60,7 @@ static char *libdir = LIBDIR;
6060
staticchar*datadir=PGSHAREDIR;
6161
staticchar*host_platform=HOST_TUPLE;
6262
staticchar*makeprog=MAKEPROG;
63+
staticchar*shellprog=SHELLPROG;
6364

6465
/* currently we can use the same diff switches on all platforms */
6566
staticconstchar*basic_diff_opts="-w";
@@ -630,8 +631,20 @@ spawn_process(const char *cmdline)
630631
}
631632
if (pid==0)
632633
{
633-
/* In child */
634-
exit(system(cmdline) ?1 :0);
634+
/*
635+
* In child
636+
*
637+
* Instead of using system(), exec the shell directly, and tell it
638+
* to "exec" the command too. This saves two useless processes
639+
* per parallel test case.
640+
*/
641+
char*cmdline2=malloc(strlen(cmdline)+6);
642+
643+
sprintf(cmdline2,"exec %s",cmdline);
644+
execl(shellprog,shellprog,"-c",cmdline2,NULL);
645+
fprintf(stderr,_("%s: could not exec \"%s\": %s\n"),
646+
progname,shellprog,strerror(errno));
647+
exit(1);/* not exit_nicely here... */
635648
}
636649
/* in parent */
637650
returnpid;
@@ -648,7 +661,7 @@ spawn_process(const char *cmdline)
648661

649662
if (!CreateProcess(NULL,cmdline2,NULL,NULL, FALSE,0,NULL,NULL,&si,&pi))
650663
{
651-
fprintf(stderr,_("failed to start process for \"%s\": %lu\n"),
664+
fprintf(stderr,_("could not start process for \"%s\": %lu\n"),
652665
cmdline2,GetLastError());
653666
exit_nicely(2);
654667
}
@@ -684,7 +697,7 @@ psql_start_test(const char *testname)
684697

685698
if (pid==INVALID_PID)
686699
{
687-
fprintf(stderr,_("failed to start process for test %s\n"),
700+
fprintf(stderr,_("could not start process for test %s\n"),
688701
testname);
689702
exit_nicely(2);
690703
}
@@ -918,7 +931,7 @@ wait_for_tests(PID_TYPE *pids, int num_tests)
918931

919932
if (p==-1)
920933
{
921-
fprintf(stderr,_("failed to wait(): %s\n"),strerror(errno));
934+
fprintf(stderr,_("could not wait(): %s\n"),strerror(errno));
922935
exit_nicely(2);
923936
}
924937
for (i=0;i<num_tests;i++)
@@ -938,7 +951,7 @@ wait_for_tests(PID_TYPE *pids, int num_tests)
938951
r=WaitForMultipleObjects(num_tests,pids, TRUE,INFINITE);
939952
if (r!=WAIT_OBJECT_0)
940953
{
941-
fprintf(stderr,_("failed to wait for commands to finish: %lu\n"),
954+
fprintf(stderr,_("could not wait for commands to finish: %lu\n"),
942955
GetLastError());
943956
exit_nicely(2);
944957
}
@@ -1228,7 +1241,7 @@ main(int argc, char *argv[])
12281241
intc;
12291242
inti;
12301243
intoption_index;
1231-
charbuf[MAXPGPATH];
1244+
charbuf[MAXPGPATH*4];
12321245

12331246
staticstructoptionlong_options[]= {
12341247
{"help",no_argument,NULL,'h'},
@@ -1431,14 +1444,6 @@ main(int argc, char *argv[])
14311444
exit_nicely(2);
14321445
}
14331446

1434-
/*
1435-
* XXX Note that because we use system() to launch the subprocess,
1436-
* the returned postmaster_pid is not really the PID of the
1437-
* postmaster itself; on most systems it'll be the PID of a parent
1438-
* shell process. This is OK for the limited purposes we currently
1439-
* use postmaster_pid for, but beware!
1440-
*/
1441-
14421447
/*
14431448
* Wait till postmaster is able to accept connections (normally only
14441449
* a second or so, but Cygwin is reportedly *much* slower). Don't

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp