From owner-freebsd-rc@freebsd.org Fri Oct 2 16:13:36 2015 Return-Path: Delivered-To: freebsd-rc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20F8CA0DBD7; Fri, 2 Oct 2015 16:13:36 +0000 (UTC) (envelope-from cv@jet9.net) Received: from mail1.ssnab.net (mail1.ssnab.net [85.143.179.24]) by mx1.freebsd.org (Postfix) with ESMTP id D779B150C; Fri, 2 Oct 2015 16:13:35 +0000 (UTC) (envelope-from cv@jet9.net) Received: from inc.ru (localhost [127.0.0.1]) by mail1.ssnab.net (Postfix) with SMTP id DA8CDC08C9; Fri, 2 Oct 2015 19:08:37 +0300 (MSK) X-Antispam-passed: yes X-Antispam: yes Received: from [95.27.88.77] (account cv@serversnab.ru HELO new-cv.home) by inc.ru (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 24013723; Fri, 02 Oct 2015 19:08:37 +0300 Message-ID: <560EAC05.6050308@jet9.net> Date: Fri, 02 Oct 2015 19:08:37 +0300 From: Cyril Vechera User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 MIME-Version: 1.0 To: dougb@FreeBSD.org, freebsd-hackers@freebsd.org, freebsd-rc@freebsd.org Subject: rc(8) parallel tasks Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2015 16:13:36 -0000 Hi there. We've got a small launcher script (~250 loc) for parallel services start/stop etc. It is used on our embedded systems and our users containers. And I've done a proof of concept for implanting it to the FreeBSD's standard /etc/rc for execution starting scripts in parallel. It gave me a boot time reduction of rc part from 27 to 7 seconds, mostly on eliminating jams for network or other long-latency resources waiting. The launcher is written in pure POSIX shell and uses FIFOs (named pipes) as a mutexes for synchronization. So it is embedded into /etc/rc and /etc/rc.d preserving rc.subr preloading. As a primary requirement, it guarantees topological order (strict partial order) defined by dependencies. It requires only POSIX shell, FreeBSD or Linux kernel, mkfifo and a writeable file system. Due to last requirement, it can be run on the late stage or should be supplied by some kinf of writtable fs, ie tmpfs. The FreeBSD-integrated version uses standard rcorder annotations (REQUIRE, BEFORE and PROVIDE) and there's no need to change rc.d scripts It's not a full init replacement or a kind of services supervision tool. It only starts or invokes a group of scripts in parallel with resolving and assuring execution in dependencies order. Please take a look at the script and patch set for FreeBSD: https://github.com/cvss/jet9-multitask-init/blob/master/jet9-multitask-init https://github.com/cvss/jet9-multitask-init/tree/master/examples/freebsd -- Cyril Vechera