From owner-freebsd-hackers@freebsd.org Thu Jul 20 08:19:09 2017 Return-Path: Delivered-To: freebsd-hackers@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 CAAEFDABB8B for ; Thu, 20 Jul 2017 08:19:09 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8FD3E1888 for ; Thu, 20 Jul 2017 08:19:09 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 932E3260628; Thu, 20 Jul 2017 10:15:46 +0200 (CEST) Subject: Re: Relationship between ncallout and callwheelsize To: Sebastian Huber , FreeBSD References: <8ba43394-41e4-f06c-a8c6-12b773d185c4@embedded-brains.de> From: Hans Petter Selasky Message-ID: <757f601d-96ad-0334-a663-963e8da6cb0e@selasky.org> Date: Thu, 20 Jul 2017 10:13:31 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <8ba43394-41e4-f06c-a8c6-12b773d185c4@embedded-brains.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jul 2017 08:19:10 -0000 On 07/20/17 08:59, Sebastian Huber wrote: > Hello, > > I noticed on a LPC4088 running at 96MHz from external SDRAM that the > callout_process() function needs a lot of time even if no callouts are > active. The reason is that on a 32-bit architecture with only 13 general > purpose registers this function needs a lot of load/store operations. So > I tried to reduce the complexity by using compile time constants. I > don't understand why the callwheelsize and the timeout(9) > pre-allocations are related: > > ncallout = imin(16 + maxproc + maxfiles, 18508); > TUNABLE_INT_FETCH("kern.ncallout", &ncallout); > > /* > * Calculate callout wheel size, should be next power of two higher > * than 'ncallout'. > */ > callwheelsize = 1 << fls(ncallout); > callwheelmask = callwheelsize - 1; > > The size of the wheel should be related to typical timeout values to > balance memory size and hash collisions. Why is there a connection to > the timeout(9) pre-allocations? > Hi, The calloutwheel is simply an optimisation. If you don't need many callouts, maybe a per-CPU list will be enough for your purpose. --HPS