Changeset: d6052d7e34e9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d6052d7e34e9
Modified Files:
MonetDB.spec
common/stream/stream.c
configure.ag
debian/rules
monetdb5/modules/mal/mal_mapi.c
tools/merovingian/daemon/client.c
tools/merovingian/daemon/controlrunner.c
tools/merovingian/daemon/discoveryrunner.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/daemon/multiplex-funnel.c
tools/mserver/Makefile.ag
Branch: default
Log Message:
Added support for the Google profiler library.
The library is linked into mserver5 when
1. it is found
2. when compiling from Mercurial sources
3. when not optimizing
Or when using --enable-profiler.
By default, the profiler does nothing. It only profiles the code when
the environment variable CPUPROFILE is set (to the path of the file
into which the profile is collected) when starting mserver5.
diffs (288 lines):
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -967,6 +967,7 @@ export CFLAGS
--enable-mapi=yes \
--enable-netcdf=no \
--enable-odbc=yes \
+ --enable-profiler=no \
--enable-py2integration=%{?with_py2integration:yes}%{!?with_py2integration:no} \
--enable-py3integration=%{?with_py3integration:yes}%{!?with_py3integration:no} \
--enable-rintegration=%{?with_rintegration:yes}%{!?with_rintegration:no} \
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -2500,6 +2500,8 @@ socket_read(stream *restrict s, void *re
.events = POLLIN};
ret = poll(&pfd, 1, (int) s->timeout);
+ if (ret == -1 && errno == EINTR)
+ continue;
if (ret == -1 || (pfd.revents & POLLERR)) {
s->errnr = MNSTR_READ_ERROR;
return -1;
@@ -2550,6 +2552,8 @@ socket_read(stream *restrict s, void *re
}
#else
nr = read(s->stream_data.s, buf, size);
+ if (nr == -1 && errno == EINTR)
+ continue;
if (nr == -1) {
s->errnr = MNSTR_READ_ERROR;
return -1;
@@ -2643,6 +2647,8 @@ socket_isalive(stream *s)
pfd = (struct pollfd){.fd = fd};
if ((ret = poll(&pfd, 1, 0)) == 0)
return 1;
+ if (ret == -1 && errno == EINTR)
+ return socket_isalive(s);
if (ret < 0 || pfd.revents & (POLLERR | POLLHUP))
return 0;
assert(0); /* unexpected revents value */
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -134,20 +134,22 @@ AS_CASE([$CC],
AS_IF([test -f "$srcdir"/vertoo.data],
[
# Developers compiling from Mercurial:
- # default is --enable-strict --enable-assert --enable-debug
--disable-optimize --enable-developer
+ # default is --enable-strict --enable-assert --enable-debug
--disable-optimize --enable-developer --enable-profiler=auto
dft_strict=yes
dft_assert=yes
dft_debug=yes
dft_optimize=no
- dft_developer=yes],
+ dft_developer=yes
+ dft_profiler=auto],
[
# Users compiling from source tarball(s):
- # default is --disable-strict --disable-assert --disable-debug
--disable-optimize --disable-developer
+ # default is --disable-strict --disable-assert --disable-debug
--disable-optimize --disable-developer --disable-profiler
dft_strict=no
dft_assert=no
dft_debug=no
dft_optimize=auto
- dft_developer=no])
+ dft_developer=no
+ dft_profiler=no])
AC_ARG_ENABLE([developer],
[AS_HELP_STRING([--enable-developer],
@@ -293,6 +295,14 @@ AC_ARG_ENABLE([strict],
[enable_strict=$enableval],
[enable_strict=$dft_strict])
+# when optimizing, don't enable the profiler (unless it's explicitly enabled)
+AS_VAR_IF([enable_optimize], [yes], [dft_profiler=no])
+AC_ARG_ENABLE([profiler],
+ [AS_HELP_STRING([--enable-profiler],
+ [add support for the Google profiler library (default=auto for
development sources)])],
+ [enable_profiler=$enableval],
+ [enable_profiler=$dft_profiler])
+
dft_sanitizer=no
AC_ARG_ENABLE([sanitizer],
[AS_HELP_STRING([--enable-sanitizer],
@@ -2168,6 +2178,19 @@ AC_SUBST([LIBLAS_LIBS])
AM_CONDITIONAL([HAVE_LIDAR], [test "x$have_lidar" = xyes -o "x$have_lidar" =
xauto])
+dnl check for profiler library
+AS_CASE([$enable_profiler],
+ [no], [have_profiler=no],
+ [
+ PKG_CHECK_MODULES([PROFILER], [libprofiler],
+ [have_profiler=yes],
+ [have_profiler=no; why_not_profiler="(profiler library
not found)"])
+ AS_VAR_IF([have_profiler], [yes], [
+ AC_DEFINE([HAVE_LIBPROFILER], 1, [Define if you have
the profiler library])
+ AC_SUBST([PKG_PROFILER], [libprofiler])])])
+AM_CONDITIONAL([HAVE_LIBPROFILER], [test x$have_profiler != xno])
+
+
# checks for header files
AC_HEADER_STDBOOL
# NOTE: these header files are in alphabetical order to ease maintenance
diff --git a/debian/rules b/debian/rules
--- a/debian/rules
+++ b/debian/rules
@@ -25,6 +25,7 @@ override_dh_auto_configure:
--enable-netcdf=no \
--enable-odbc=yes \
--enable-optimize=yes \
+ --enable-profiler=no \
--enable-py2integration=yes \
--enable-py3integration=yes \
--enable-rintegration=yes \
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -278,13 +278,6 @@ SERVERlistenThread(SOCKET *Sock)
{
char *msg = 0;
int retval;
-#ifdef HAVE_POLL
- struct pollfd pfd[2];
- nfds_t npfd;
-#else
- struct timeval tv;
- fd_set fds;
-#endif
SOCKET sock = INVALID_SOCKET;
SOCKET usock = INVALID_SOCKET;
SOCKET msgsock = INVALID_SOCKET;
@@ -300,6 +293,8 @@ SERVERlistenThread(SOCKET *Sock)
do {
#ifdef HAVE_POLL
+ struct pollfd pfd[2];
+ nfds_t npfd;
npfd = 0;
if (sock != INVALID_SOCKET)
pfd[npfd++] = (struct pollfd) {.fd = sock, .events =
POLLIN};
@@ -307,9 +302,13 @@ SERVERlistenThread(SOCKET *Sock)
if (usock != INVALID_SOCKET)
pfd[npfd++] = (struct pollfd) {.fd = usock, .events =
POLLIN};
#endif
- /* Wait up to 0.025 seconds (0.001 if testing) */
- retval = poll(pfd, npfd, GDKdebug & FORCEMITOMASK ? 10 : 25);
+ /* Wait up to 0.1 seconds (0.01 if testing) */
+ retval = poll(pfd, npfd, GDKdebug & FORCEMITOMASK ? 10 : 100);
+ if (retval == -1 && errno == EINTR)
+ continue;
#else
+ struct timeval tv;
+ fd_set fds;
FD_ZERO(&fds);
if (sock != INVALID_SOCKET)
FD_SET(sock, &fds);
@@ -317,9 +316,10 @@ SERVERlistenThread(SOCKET *Sock)
if (usock != INVALID_SOCKET)
FD_SET(usock, &fds);
#endif
- /* Wait up to 0.025 seconds (0.001 if testing) */
- tv.tv_sec = 0;
- tv.tv_usec = GDKdebug & FORCEMITOMASK ? 10000 : 25000;
+ /* Wait up to 0.1 seconds (0.01 if testing) */
+ tv = (struct timeval) {
+ .tv_usec = GDKdebug & FORCEMITOMASK ? 10000 : 100000,
+ };
/* temporarily use msgsock to record the larger of sock and
usock */
msgsock = sock;
diff --git a/tools/merovingian/daemon/client.c
b/tools/merovingian/daemon/client.c
--- a/tools/merovingian/daemon/client.c
+++ b/tools/merovingian/daemon/client.c
@@ -438,8 +438,7 @@ acceptConnections(int sock, int usock)
FD_SET(usock, &fds);
/* Wait up to 5 seconds */
- tv.tv_sec = 5;
- tv.tv_usec = 0;
+ tv = (struct timeval) {.tv_sec = 5};
retval = select((sock > usock ? sock : usock) + 1,
&fds, NULL, NULL, &tv);
#endif
diff --git a/tools/merovingian/daemon/controlrunner.c
b/tools/merovingian/daemon/controlrunner.c
--- a/tools/merovingian/daemon/controlrunner.c
+++ b/tools/merovingian/daemon/controlrunner.c
@@ -120,6 +120,7 @@ recvWithTimeout(int msgsock, stream *fdi
#ifdef HAVE_POLL
struct pollfd pfd = (struct pollfd) {.fd = msgsock, .events = POLLIN};
+ /* Wait up to 1 second. If a client doesn't make this, it's too slow */
retval = poll(&pfd, 1, 1000);
#else
fd_set fds;
@@ -129,8 +130,7 @@ recvWithTimeout(int msgsock, stream *fdi
FD_SET(msgsock, &fds);
/* Wait up to 1 second. If a client doesn't make this, it's too slow */
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv = struct timeval) {.tv_sec = 1};
retval = select(msgsock + 1, &fds, NULL, NULL, &tv);
#endif
if (retval <= 0) {
@@ -1047,6 +1047,7 @@ controlRunner(void *d)
Mfprintf(_mero_ctlerr, "malloc failed");
break;
}
+ /* limit waiting time in order to check whether we need to exit
*/
#ifdef HAVE_POLL
pfd = (struct pollfd) {.fd = usock, .events = POLLIN};
retval = poll(&pfd, 1, 1000);
@@ -1054,9 +1055,7 @@ controlRunner(void *d)
FD_ZERO(&fds);
FD_SET(usock, &fds);
- /* limit waiting time in order to check whether we need to exit
*/
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv = (struct timeval) {.tv_sec = 1};
retval = select(usock + 1, &fds, NULL, NULL, &tv);
#endif
if (retval == 0) {
diff --git a/tools/merovingian/daemon/discoveryrunner.c
b/tools/merovingian/daemon/discoveryrunner.c
--- a/tools/merovingian/daemon/discoveryrunner.c
+++ b/tools/merovingian/daemon/discoveryrunner.c
@@ -406,8 +406,7 @@ discoveryRunner(void *d)
#else
FD_ZERO(&fds);
FD_SET(sock, &fds);
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv = (struct timeval) {.tv_sec = 1};
nread = select(sock + 1, &fds, NULL, NULL, &tv);
#endif
if (nread != 0)
diff --git a/tools/merovingian/daemon/merovingian.c
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -196,8 +196,7 @@ logListener(void *x)
/* wait max 1 second, tradeoff between performance and being
* able to catch up new logger streams */
#ifndef HAVE_POLL
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv = (struct timeval) {.tv_sec = 1};
FD_ZERO(&readfds);
#endif
nfds = 0;
diff --git a/tools/merovingian/daemon/multiplex-funnel.c
b/tools/merovingian/daemon/multiplex-funnel.c
--- a/tools/merovingian/daemon/multiplex-funnel.c
+++ b/tools/merovingian/daemon/multiplex-funnel.c
@@ -82,8 +82,7 @@ MFconnectionManager(void *d)
FD_SET(mfpipe[0], &fds);
/* wait up to 5 seconds */
- tv.tv_sec = 5;
- tv.tv_usec = 0;
+ tv = (struct timeval) {.tv_sec = 5};
i = select(mfpipe[0] + 1, &fds, NULL, NULL, &tv);
#endif
if (i == 0)
@@ -730,8 +729,7 @@ multiplexThread(void *d)
}
/* wait up to 1 second. */
- tv.tv_sec = 1;
- tv.tv_usec = 0;
+ tv = (struct timeval) {.tv_sec = 1};
r = select(msock + 1, &fds, NULL, NULL, &tv);
#endif
diff --git a/tools/mserver/Makefile.ag b/tools/mserver/Makefile.ag
--- a/tools/mserver/Makefile.ag
+++ b/tools/mserver/Makefile.ag
@@ -68,7 +68,8 @@ bin_mserver5 = {
$(lz4_LIBS) \
$(liblzma_LIBS) \
$(curl_LIBS) \
- $(LTLIBICONV)
+ $(LTLIBICONV) \
+ $(PROFILER_LIBS)
}
bin_shutdowntest = {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list