From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 5 20:04:31 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89C6F106564A; Sat, 5 Feb 2011 20:04:31 +0000 (UTC) (envelope-from cvs-src@yandex.ru) Received: from forward15.mail.yandex.net (forward15.mail.yandex.net [95.108.130.119]) by mx1.freebsd.org (Postfix) with ESMTP id 340658FC14; Sat, 5 Feb 2011 20:04:30 +0000 (UTC) Received: from smtp11.mail.yandex.net (smtp11.mail.yandex.net [95.108.130.67]) by forward15.mail.yandex.net (Yandex) with ESMTP id 61EEA4458C7C; Sat, 5 Feb 2011 23:04:29 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1296936269; bh=+ePWuV8zBhSY2jC4ZlBObVqNXf4+M81jWIeboV5Vg6U=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=VTk0n4pHXMuVMw+Ssld2w7G+wFwHVnoy8PWPww3pEvbL3YAG9vC8Pm3ukMR4gxjoI csPDKzIx8CQcvsmdICOjyanld8ZwiAlc6WkmR2NOXZi6ECO2KWCjADzNPC9M2cCvg8 q20wViYC1aAWwnQcxjjc0W9u8lI0jpWivanz7oqM= Received: from smeshariki2.local (unknown [213.138.85.225]) by smtp11.mail.yandex.net (Yandex) with ESMTPSA id 18E8E4CC0080; Sat, 5 Feb 2011 23:04:29 +0300 (MSK) Message-ID: <4D4DAD05.2070707@yandex.ru> Date: Sat, 05 Feb 2011 23:03:17 +0300 From: Ruslan Mahmatkhanov User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; ru-RU; rv:1.9.2.13) Gecko/20110106 Thunderbird/3.1.7 MIME-Version: 1.0 To: Ivan Voras References: <4D3CB2AF.9050003@yandex.ru> <4D4D9A4D.2070508@yandex.ru> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Cc: freebsd-hackers@freebsd.org, davidxu@freebsd.org Subject: Re: Tracking down a problem with php on FreeBSD 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: Sat, 05 Feb 2011 20:04:31 -0000 05.02.2011 22:43, Ivan Voras пишет: >>>> - `top -mio` shows very high (80000-90000 for VCSW) VCSW/IVCSW values >>>> for php-fpm processes and LA is more than 120 > > I think this is significant, especially with this: > >> When attaching to any hanging php-fpm proccess with truss, than i see a lot >> of this calls: >> sched_yield(0x80516c000,0x1,0x4d4828b6,0x8012ef45c,0xffffffff808bfd80,0x7fffffffa078) >> = 0 (0x0) >> sched_yield(0x80516c000,0x1,0x4d4828b6,0x8012ef45c,0xffffffff808bfd80,0x7fffffffa078) >> = 0 (0x0) >> sched_yield(0x80516c000,0x1,0x4d4828b6,0x8012ef45c,0xffffffff808bfd80,0x7fffffffa078) >> = 0 (0x0) >> sched_yield(0x80516c000,0x1,0x4d4828b6,0x8012ef45c,0xffffffff808bfd80,0x7fffffffa078) >> = 0 (0x0) > > "Normal" processes of the type PHP is have no need to call > sched_yield() arbitrarily, unless they are implementing something they > shouldn't - like a synchronization primitive (semaphore/lock). If "a > lot" means "of the same order of magnitude as your VCSW rate", this is > the reason for it. > > I've analyzed my php-cgi binary and modules and they don't use sched_yield. > > And yes, grepping for it in the source finds it only in FPM: > > sapi/fpm/fpm/fpm_atomic.h:140: sched_yield(); > > It seems they are trying to implement a spinlock by hand, instead of > using what the OS provides. (on the other hand, the implementation > might be correct but they may be using it wrong). > > In any case, this points to bugs in FPM. if so, unfortunately I can't > help you further. Ok, thank you. I'll try to ask FPM people once again (i sent them the same message that is in hackers@ but with no response) > If you really want to continue using FPM, I guess you should probably > replace this hand-made lock implementation by sem(4) or see if > "robust" pthreads mutexes can be committed and MFCed (maybe with David > Xu). Can you please tell me more what you mean by ""robust" pthreads mutexes" and if it can help somehow without modifying fpm code? Is there any patches that we can apply to our development server to play with? > > Here is the FPM file: > > http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_atomic.h?revision=305417&view=markup -- Regards, Ruslan