From owner-freebsd-arch@FreeBSD.ORG Wed Apr 4 19:36:16 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C8052106564A; Wed, 4 Apr 2012 19:36:16 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id A185D8FC12; Wed, 4 Apr 2012 19:36:16 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 172F8B943; Wed, 4 Apr 2012 15:36:16 -0400 (EDT) From: John Baldwin To: phk@freebsd.org Date: Wed, 4 Apr 2012 14:33:05 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201204041433.05652.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 04 Apr 2012 15:36:16 -0400 (EDT) Cc: arch@freebsd.org Subject: EVENTHANDLER()'s X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Apr 2012 19:36:16 -0000 So many years ago (2004), you removed support for "fast" EVENTHANDLER() objects. I was looking at this today and I kind of think we should actually undo that, but perhaps instead what we should do is make all EVENTHANDLER()'s "fast". No one creates eventhandlers with dynamic names (nor have they ever AFAIK), they all have static names. However, each time someone calls EVENTHANDLER_INVOKE() we do an O(n) loop with strcmp's to lookup the list by it's name via a string. It seems to me that we would do just fine with having all the eventhandler lists be global variables like the old "fast" variants and the string "tag" passed to all the EVENTHANDLER macros would just be used to set the variable name (exactly like the old "fast" variants). This would remove all the O(n) lookups, and we could further optimize _INVOKE() to not do any locking if the list is empty to avoid overhead in the case where there are no active hooks. -- John Baldwin