The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Jesse Gross <jesse@nicira.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	David Rientjes <rientjes@google.com>
Subject: Re: [PATCH] flex_array: Avoid divisions when accessing elements.
Date: Wed, 27 Apr 2011 09:13:39 -0700	[thread overview]
Message-ID: <1303920819.9308.19723.camel@nimitz> (raw)
In-Reply-To: <1303850501-16249-1-git-send-email-jesse@nicira.com>

On Tue, 2011-04-26 at 13:41 -0700, Jesse Gross wrote:
> On most architectures division is an expensive operation and
> accessing an element currently requires four of them.  This
> performance penalty effectively precludes flex arrays from
> being used on any kind of fast path.  However, two of these
> divisions can be handled at creation time and the others can
> be replaced by a reciprocal divide, completely avoiding real
> divisions on access. 

flex_array.c has a nice table for how many objects can be allocated:

 * Element size | Objects | Objects |
 * PAGE_SIZE=4k |  32-bit |  64-bit |
 * ---------------------------------|
 *      1 bytes | 4186112 | 2093056 |
 *      2 bytes | 2093056 | 1046528 |
 *      3 bytes | 1395030 |  697515 |
 *      4 bytes | 1046528 |  523264 |
 *     32 bytes |  130816 |   65408 |
 *     33 bytes |  126728 |   63364 |
 *   2048 bytes |    2044 |    1022 |
 *   2049 bytes |    1022 |     511 |
 *       void * | 1046528 |  261632 |

This patch changes that a bit.  Would you mind updating it?

-- Dave


  reply	other threads:[~2011-04-27 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 20:41 [PATCH] flex_array: Avoid divisions when accessing elements Jesse Gross
2011-04-27 16:13 ` Dave Hansen [this message]
2011-04-29  1:48   ` Jesse Gross
  -- strict thread matches above, loose matches on Subject: below --
2011-05-02 17:26 [PATCH] flex_array: avoid " Eric Paris
2011-05-02 17:36 ` Dave Hansen
2011-05-02 20:23   ` Jesse Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1303920819.9308.19723.camel@nimitz \
    --to=dave@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=jesse@nicira.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox