From owner-freebsd-arch@freebsd.org Sun Oct 29 16:47:21 2017 Return-Path: Delivered-To: freebsd-arch@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 6648DE46818 for ; Sun, 29 Oct 2017 16:47:21 +0000 (UTC) (envelope-from matt.joras@gmail.com) Received: from mail-pf0-f172.google.com (mail-pf0-f172.google.com [209.85.192.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4165C843A1; Sun, 29 Oct 2017 16:47:20 +0000 (UTC) (envelope-from matt.joras@gmail.com) Received: by mail-pf0-f172.google.com with SMTP id b85so8884903pfj.13; Sun, 29 Oct 2017 09:47:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6g6mrjvA4g3hZMjRXZEkI04GIIBg4OOR2dqlkQiTiR0=; b=ICPV6vKdBMljL/CjG0eiqChK4Bg7RI8UgCsp0eMss5DAStEEqwYq7CvHeWwTj0DPzw KRrhVygQWUppSyEE6Tp26vHzMLaPdKi+btBIja4dE8BzHkqUmUjuEhmoyjm1A/NY+ZJq 6/JviKZEVW10upcREk5FaMDbjQRgrIx99a4pZOzbZVd2LSR2DOzEPcJgg38q0u+97lj5 2n4YdT0toCLCkKw3rU+lAc526aqF5s+uiECLZlHIy2j4mF/jtEykts+z1afB3BKA1CVk ht2J6ZjVEiYG5q+SNxQuVto02DcB6hrkJ2W7zr9AlFCrLbRQqPLUX6QjsJRWNgoswaQ4 PiQA== X-Gm-Message-State: AMCzsaXjssjhSVZCzmxalAXHJDHCSKUbQGFm+vQU4Cugr7KHP2b6uoNG BOauBoyLMAJK1pbauW8SX5zA6eFe X-Google-Smtp-Source: ABhQp+TqUWzbQ26E0PN0CRUcnHj5UIIKNykZwC/GOyxRY48i8pxZeHBh/M85LhHbvjsgNTj3o/DfGQ== X-Received: by 10.99.53.11 with SMTP id c11mr5410576pga.162.1509295130472; Sun, 29 Oct 2017 09:38:50 -0700 (PDT) Received: from [192.168.2.123] (174-24-242-218.tukw.qwest.net. [174.24.242.218]) by smtp.gmail.com with ESMTPSA id c1sm23265362pfa.12.2017.10.29.09.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 09:38:49 -0700 (PDT) Subject: Re: Allow faster eventhandler dispatching by keeping pointers to handler lists. To: Ian Lepore , "freebsd-arch@FreeBSD.org" References: <1509243567.56824.103.camel@freebsd.org> <3a71dd31-99cb-c891-9d52-a7f2e7010011@FreeBSD.org> <1509293552.21609.5.camel@freebsd.org> <1509294247.21609.12.camel@freebsd.org> From: Matt Joras Message-ID: <7b59ff3d-3458-0bca-e6b4-13454b13efb0@FreeBSD.org> Date: Sun, 29 Oct 2017 09:38:48 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1509294247.21609.12.camel@freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Oct 2017 16:47:21 -0000 On 10/29/2017 09:24, Ian Lepore wrote: > On Sun, 2017-10-29 at 10:12 -0600, Ian Lepore wrote: >> Actually, it looks like we've done nearly identical work, modulo some >> minor naming differences (that I'm completely agnostic about), and you >> have the EHL_NONEMPTY flag that didn't occur to me until after I >> created the phab review last night. >> >> The other big difference is that mine still links the fast/static lists >> into the global list-of-lists, to preserve what I call "late loose >> binding" where an event handler can register for events before the >> event provider is present (picture a module that monitors events which >> gets loaded before a module that produces those events). >> >> It ocurred to me this morning that an optimization for mine would be to >> place any list created by eventhandler_create_list() at the end of the >> global list, on the theory that it will mostly be accessed directly via >> pointer and the items at the head of the global list should be the ones >> more likely to be searched by name. >> >> -- Ian > Oops, I apparently overlooked _eventhandler_insert_static() in your > changes.  I think if that were changed to first check whether the new > handler list already exists on the global list, our changes really > would be essentially identical. > > -- Ian Indeed. The other difference I noted is that my version statically-allocates the actual list structs, and relies on static initialization, whereas yours uses malloc and initializes them explicitly. How would you like to proceed? Matt