From nobody@FreeBSD.org  Tue Feb 14 20:27:40 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 88BDE106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 14 Feb 2012 20:27:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 78A658FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 14 Feb 2012 20:27:40 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q1EKRdKg013888
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 14 Feb 2012 20:27:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q1EKRdlu013887;
	Tue, 14 Feb 2012 20:27:39 GMT
	(envelope-from nobody)
Message-Id: <201202142027.q1EKRdlu013887@red.freebsd.org>
Date: Tue, 14 Feb 2012 20:27:39 GMT
From: Eugen Konkov <kes-kes@yandex.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: wrong de optimization
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         165153
>Category:       misc
>Synopsis:       wrong de optimization
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 14 20:30:10 UTC 2012
>Closed-Date:    Wed Feb 15 09:56:41 UTC 2012
>Last-Modified:  Wed Feb 15 09:56:41 UTC 2012
>Originator:     Eugen Konkov
>Release:        10.0-CURRENT
>Organization:
ISP FreeLine
>Environment:
>Description:
you must revert commit 231585 because of next:
there were
	/*
	 * Microoptimisations for a ng_socket with no
	 * hooks, or with a single hook, which is a
	 * common case.
	 */
which says that if node has no hooks DO NOTHING
	if (node->nd_numhooks == 0)
		return (NULL);

in r231585 there is no such check so for node with no hooks there were useless timespend in FOREACH loop. instead of fast 'return (NULL)' as it were before
>How-To-Repeat:

>Fix:
revert 231585 

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: tijl 
Responsible-Changed-When: Wed Feb 15 09:48:24 CET 2012 
Responsible-Changed-Why:  
Assign to committer of r231585. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165153 
State-Changed-From-To: open->closed 
State-Changed-By: glebius 
State-Changed-When: Wed Feb 15 09:53:56 UTC 2012 
State-Changed-Why:  
Eugen, please use just email for such kind of discussions. 

The code removed would return true only for a node with 
no hooks, that exist for an extremely short period of time. 
I even doubt that ng_findhook can be called for such a node, 
since it is marked as invalid. But the NULL check would 
be processed for every normal ng_findhook call, that would 
be a couple of additional CPU operations for every call, 
thus not an optimisation definitely. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165153 
>Unformatted:
