From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 30 14:44:40 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4433016A41C for ; Thu, 30 Jun 2005 14:44:40 +0000 (GMT) (envelope-from andrit@ukr.net) Received: from storage.ukr.net (storage.ukr.net [212.42.65.69]) by mx1.FreeBSD.org (Postfix) with ESMTP id EEC5543D1F for ; Thu, 30 Jun 2005 14:44:39 +0000 (GMT) (envelope-from andrit@ukr.net) Received: from dialup-146.222.sitel.com.ua ([217.27.146.222] helo=ertpc) by storage.ukr.net with smtp ID 1Do0HN-000HC9-J8 ; Thu, 30 Jun 2005 17:44:38 +0300 Message-ID: <003901c57d82$37891b80$de921bd9@ertpc> From: "Andriy Tkachuk" To: "Max Laier" , References: <000d01c57cf7$b9b6f9f0$29931bd9@ertpc> <200506301415.38106.max@love2party.net> Date: Thu, 30 Jun 2005 17:35:17 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Cc: Subject: Re: hot path optimizations in uma_zalloc() & uma_zfree() 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: Thu, 30 Jun 2005 14:44:40 -0000 I just checked the object code - you right, it almost the same: - bucket->ub_bucket[bucket->ub_cnt] = item; - 22b9: 0f bf 43 08 movswl 0x8(%ebx),%eax - 22bd: 8b 4d 0c mov 0xc(%ebp),%ecx - 22c0: 89 4c 83 0c mov %ecx,0xc(%ebx,%eax,4) - bucket->ub_cnt++; - 22c4: 8d 42 01 lea 0x1(%edx),%eax - 22c7: 66 89 43 08 mov %ax,0x8(%ebx) + bucket->ub_bucket[bucket->ub_cnt++] = item; + 22b9: 0f bf c2 movswl %dx,%eax + 22bc: 8b 4d 0c mov 0xc(%ebp),%ecx + 22bf: 89 4c 83 0c mov %ecx,0xc(%ebx,%eax,4) + 22c3: 8d 42 01 lea 0x1(%edx),%eax + 22c6: 66 89 43 08 mov %ax,0x8(%ebx) but still there is some minor difference in first line. I'm not familiar with assembler, can somebody explain whether this difference is assential or not? in decrementation there is no difference at all: - bucket->ub_cnt--; + item = bucket->ub_bucket[--bucket->ub_cnt]; 1bbe: 66 ff 49 08 decw 0x8(%ecx) - item = bucket->ub_bucket[bucket->ub_cnt]; 1bc2: 0f bf 41 08 movswl 0x8(%ecx),%eax 1bc6: 8b 44 81 0c mov 0xc(%ecx,%eax,4),%eax 1bca: 89 45 f0 mov %eax,0xfffffff0(%ebp) ----- Original Message ----- From: "Max Laier" To: Cc: "ant" Sent: Thursday, June 30, 2005 3:15 PM Subject: Re: hot path optimizations in uma_zalloc() & uma_zfree() > Another optimization is very trivial, for example: > - bucket->ub_cnt--; > - item = bucket->ub_bucket[bucket->ub_cnt]; > + item = bucket->ub_bucket[--bucket->ub_cnt]; > (see the patch) Might be me, but this doesn't change the generated object code at all (modulo the changed __line__ in debugging).