cmogstored dev/user discussion/issues/patches/etc
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] cmogstored 1.5.0 - a mogstored alternative
@ 2015-11-21  2:58  5% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-11-21  2:58 UTC (permalink / raw)
  To: mogile, cmogstored-public

cmogstored is an alternative implementation of the "mogstored" storage
component of MogileFS.  cmogstored is implemented in C and does not use
Perl at runtime.  cmogstored is the only component you need to install
on a MogileFS storage node.

Changes since 1.4.3:

    cmogstored 1.5.0 - vfork, systemd, 416 codes

    A bunch of minor changes; most notable is systemd-style socket
    activation support.  This was easy-to-add since we've always had
    socket activation support for nginx-style SIGUSR2 upgrades.

    This places no link or runtime dependency on libsystemd, so the
    LISTEN_FDS and LISTEN_PID environment variables may be used in other
    init systems as well.  While I have my own reservations about
    systemd itself, I also strongly believe in using socket activation
    to prevent downtime.  Existing behavior with CMOGSTORED_FD
    (used for SIGUSR2 upgrades) is now documented in the manpage and
    will always supported.

    We've also added vfork support for Linux systems, allowing
    faster spawning of iostat if malloc is using too much memory.

    Behavior changes:

    Bad Range: headers return 416 responses in more cases for invalid
    ranges (e.g. miscalculated ranges such as "1--1", while
    completely wrong ones (lacking a "bytes=" prefix) are ignored
    entirely as in nginx.

    Bugfixes:

    There are also some cleanups to avoid dying on OOM in more places
    on weird systems which trigger OOM.  More work on this is ongoing.

    Also updates to the latest gnulib.git
    commit 71d39c1644762745b94e9449c45bfd716a79a5eb
    ("autoupdate") along with a change which fixes a memory leak when
    people build from cmogstored.git using gnulib
    commit c6148bca89e9465fd6ba3a10d273ec4cb58c2dbe
    or later ("mountlist: add me_mntroot field on Linux machines").

    This memory leak did not affect any released tarballs of cmogstored.
    Note, users building from git (as opposed to the tarball) will
    need gnulib commit 41d1b6c42641a5b9e21486ca2074198ee7909bd7
    ("mountlist: add support for deallocating returned list entries")
    or later (from July 2013).

    There are also various documentation updates and our mailing
    list is now readable over NNTP:

      nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.cmogstored

8 changes since v1.5.0rc0:

      doc: document CMOGSTORED_FDS in the manpage
      use vfork under Linux before execve
      README: update contact information
      misc doc updates
      add cmogstored manpage to website
      Makefile.am: distribute txt2pre in tarball
      require newer gnulib for free_mount_entry support
      cmogstored 1.5.0 - vfork, systemd, 416 codes

14 changes for 1.5.0rc0:

      doc: use "builder" RubyGem to generate Atom feed
      dev.c: fail gracefully on out-of-memory errors
      do not die on OOM when for mgmt paths
      HACKING: update URLs to reduce redirects
      http: return 416 errors in more cases for bad Ranges
      update .gitignores for latest autotools + gnulib
      Rakefile: remove text-only part from the Atom feed
      support systemd-style socket activation via environment
      set TCP listener options on inherited sockets
      doc: add example systemd config files
      use free_mount_entry from gnulib instead of rolling our own
      fix tmpdir dependency for slow Ruby tests
      doc: publish examples directory to website
      cmogstored 1.5.0rc1

http://bogomips.org/cmogstored/files/cmogstored-1.5.0.tar.gz
SHA-1: 0581285d7104ff418eed853cfbd94ab08bba4951
SHA-256: b83b954874ef201b6e6616ec3e60f517c6a01f7bc6eda1fbb3901558e34c1388

* homepage: http://bogomips.org/cmogstored/README
* git clone git://bogomips.org/cmogstored.git
* cgit: http://bogomips.org/cmogstored.git
* gitweb: http://repo.or.cz/w/cmogstored.git
* list: cmogstored-public@bogomips.org (subscription optional)
* archives: http://bogomips.org/cmogstored-public/
* nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.cmogstored

-- 
EW

^ permalink raw reply	[relevance 5%]

* [PATCH] use vfork under Linux before execve
@ 2015-11-13 23:13  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2015-11-13 23:13 UTC (permalink / raw)
  To: cmogstored-public

Given the prevalance of gigantic VM footprints due to current glibc
malloc and our potentially large number of threads, vfork can speed
up fork used for spawning iostat and SIGUSR2 upgrades.

vfork only pauses the spawning thread, so it will not affect other
I/O threads used in cmogstored; only the non-performance-critical
master thread.

Swapping 'fork()' for 'vfork()' in the following C test program
should show a large speedup under Linux.

Changing FILL to increase or decrease memory usage will respectively
decrease or increase performance improvement gain from vfork over
fork..

-----------------------------8<-------------------------
/* gcc -o x x.c -Wall -O2 -lpthread && ./x */

	#include <sys/types.h>
	#include <sys/time.h>
	#include <unistd.h>
	#include <pthread.h>
	#include <poll.h>
	#include <stdio.h>
	#include <sys/wait.h>
	#include <stdlib.h>
	#include <string.h>
	#define FILL (1024 * 1024)

static void *thfunc(void *p)
{
	void *ptr = malloc(FILL);
	memset(ptr, 1, FILL);
	poll(0, 0, -1);
	return 0;
}

int main(void)
{
	long i;
	void *ptr = malloc(FILL);
	memset(ptr, 1, FILL);

	for (i = 0; i < 100; i++) {
		pthread_t th;
		pthread_create(&th, 0, thfunc, (void *)i);
	}

	poll(0, 0, 1000);
	for (i = 0; i < 100; i++) {
		/* swapping fork with vfork increases performance on Linux */
		pid_t pid = fork();
		if (pid < 0) {
			fprintf(stderr, "ERROR: forking %m\n");
			return 1;
		}
		if (pid == 0) {
			char *argv[] = { "/bin/true", 0 };
			char *env[] = { 0 };
			execve(argv[0], argv, env);
			return 1;
		} else {
			int s;
			waitpid(pid, &s, 0);
		}
	}

	return 0;
}
---
 cmogstored.h     | 10 ++++++++++
 configure.ac     |  1 +
 iostat_process.c |  6 +++---
 upgrade.c        |  8 +++++---
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/cmogstored.h b/cmogstored.h
index 5aa7c01..4bb0716 100644
--- a/cmogstored.h
+++ b/cmogstored.h
@@ -360,6 +360,16 @@ void mog_oom_if_null(const void *);
 
 #define warn(...) error(0, 0, __VA_ARGS__)
 
+/*
+ * vfork is poorly-specified, but at least on Linux it improves
+ * performance when used for spawning iostat processes
+ */
+#if defined(HAVE_VFORK) && defined(__linux__)
+#  define mog_fork_for_exec() vfork()
+#else
+#  define mog_fork_for_exec() fork()
+#endif
+
 /* maxconns.c */
 void mog_set_maxconns(unsigned long);
 
diff --git a/configure.ac b/configure.ac
index 8bd98e2..0d551c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,6 +51,7 @@ AC_CHECK_FUNCS([ioctl])
 AC_CHECK_FUNCS([sendfile])
 AC_CHECK_FUNCS([open_memstream])
 AC_CHECK_FUNCS([posix_fadvise])
+AC_CHECK_FUNCS([vfork])
 
 dnl need LIBS=-lfreebsd-glue (but not CFLAGS=-I/usr/include/freebsd)
 AC_CHECK_FUNCS([bsd_sendfile])
diff --git a/iostat_process.c b/iostat_process.c
index 90a291f..4d7dfbf 100644
--- a/iostat_process.c
+++ b/iostat_process.c
@@ -65,7 +65,7 @@ static void dup2_or_die(int oldfd, int newfd, const char *errdesc)
 
 	if (rc < 0) {
 		syslog(LOG_CRIT, "dup2(%s) failed: %m", errdesc);
-		abort();
+		_exit(1);
 	}
 }
 
@@ -96,7 +96,7 @@ static pid_t iostat_fork_exec(int out_fd)
 
 	cmd = exec_cmd(cmd);
 
-	iostat_pid = fork();
+	iostat_pid = mog_fork_for_exec();
 	if (iostat_pid < 0) {
 		syslog(LOG_ERR, "fork() for iostat failed: %m");
 	} else if (iostat_pid > 0) {
@@ -111,7 +111,7 @@ static pid_t iostat_fork_exec(int out_fd)
 		mog_intr_enable();
 		execl("/bin/sh", "sh", "-c", cmd, (char *)NULL);
 		syslog(LOG_CRIT, "execl(%s) failed: %m", cmd);
-		abort();
+		_exit(1);
 	}
 	mog_free(cmd);
 	return iostat_pid;
diff --git a/upgrade.c b/upgrade.c
index 1311ebe..82a7b28 100644
--- a/upgrade.c
+++ b/upgrade.c
@@ -125,13 +125,14 @@ pid_t mog_upgrade_spawn(void)
 
 	assert(dst[bytes - 1] == ',' && "not comma-terminated no listeners?");
 	dst[bytes - 1] = '\0'; /* kill the last comma */
+	start.envp[0] = dst;
 
-	pid = fork();
+	pid = mog_fork_for_exec();
 	if (pid == 0) {
-		start.envp[0] = dst;
 		mog_svc_upgrade_prepare();
 		execve(execfile, start.argv, start.envp);
-		die_errno("execve %s", execfile);
+		syslog(LOG_ERR, "execve %s failed for upgrade: %m", execfile);
+		_exit(2);
 	} else if (pid > 0) {
 		mog_process_register(pid, MOG_PROC_UPGRADE);
 		syslog(LOG_INFO, "upgrade spawned PID:%d", pid);
@@ -143,6 +144,7 @@ out:
 	/* find_in_path does not malloc if output == input */
 	if (execfile != start.argv[0])
 		mog_free(execfile);
+	start.envp[0] = 0;
 	free(dst);
 
 	return pid;
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-11-13 23:13  7% [PATCH] use vfork under Linux before execve Eric Wong
2015-11-21  2:58  5% [ANN] cmogstored 1.5.0 - a mogstored alternative Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/cmogstored.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).