From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 14 08:08:08 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0EE4F16A41F for ; Thu, 14 Jun 2007 08:08:08 +0000 (UTC) (envelope-from danny@cs.huji.ac.il) Received: from cs1.cs.huji.ac.il (cs1.cs.huji.ac.il [132.65.16.10]) by mx1.freebsd.org (Postfix) with ESMTP id BD77B13C4B7 for ; Thu, 14 Jun 2007 08:08:07 +0000 (UTC) (envelope-from danny@cs.huji.ac.il) Received: from pampa.cs.huji.ac.il ([132.65.80.32]) by cs1.cs.huji.ac.il with esmtp id 1HykNA-000DN3-7A; Thu, 14 Jun 2007 11:08:04 +0300 X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.2 To: Garrett Cooper In-reply-to: <46700CAE.6020902@u.washington.edu> References: <466F86C6.7010006@u.washington.edu> <20070613123213.GE98927@bunrab.catwhisker.org> <46700CAE.6020902@u.washington.edu> Comments: In-reply-to Garrett Cooper message dated "Wed, 13 Jun 2007 08:26:38 -0700." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 14 Jun 2007 11:08:04 +0300 From: Danny Braniss Message-ID: Cc: hackers@freebsd.org Subject: Re: Using shell commands versus C equivalents X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2007 08:08:08 -0000 ... > Sorry -- actually I meant that (along similar lines), there was a > program with the following lines: > > vsystem("/bin/chmod +x %s", filename); > > and I replaced it with: > > chmod(filename, (mode_t) ( S_IXUSR | S_IXGRP | S_IXOTH )); > > Probably won't yield much gain overall, but every drop counts and there > are quite a few iterations performed in the pkg_* programs, in > particular dealing with X.org. chmod is one(1) system call, while system is many, for starters it's fork/exec, which btw, is quiet expensive, haven't counted, but my gut feeling it's in the 10s. So, if the program does this chmod once in a blue moon, there is no real argument, but if id does it many times, then one system call is a real winner, danny