From: "Jörn Engel" <joern@logfs.org>
To: Chris Simmonds <chris@2net.co.uk>
Cc: Arnd Bergmann <arnd@arndb.de>, Marco <marco.stornelli@gmail.com>,
Sam Ravnborg <sam@ravnborg.org>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
Linux Embedded <linux-embedded@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 06/14] Pramfs: Include files
Date: Mon, 22 Jun 2009 23:41:55 +0200 [thread overview]
Message-ID: <20090622214155.GA19332@logfs.org> (raw)
In-Reply-To: <4A3FDBFE.8050509@2net.co.uk>
On Mon, 22 June 2009 20:31:10 +0100, Chris Simmonds wrote:
>
> I disagree: that adds an unnecessary overhead for those architectures
> where the cpu byte order does not match the data structure ordering. I
> think the data structures should be native endian and when mkpramfs is
> written it can take a flag (e.g. -r) in the same way mkcramfs does.
Just to quantify this point, I've written a small crap program:
#include <stdio.h>
#include <stdint.h>
#include <byteswap.h>
#include <sys/time.h>
long long delta(struct timeval *t1, struct timeval *t2)
{
long long delta;
delta = 1000000ull * t2->tv_sec + t2->tv_usec;
delta -= 1000000ull * t1->tv_sec + t1->tv_usec;
return delta;
}
#define LOOPS 100000000
int main(void)
{
long native = 0;
uint32_t narrow = 0;
uint64_t wide = 0, native_wide = 0;
struct timeval t1, t2, t3, t4, t5;
int i;
gettimeofday(&t1, NULL);
for (i = 0; i < LOOPS; i++)
native++;
gettimeofday(&t2, NULL);
for (i = 0; i < LOOPS; i++)
narrow = bswap_32(bswap_64(narrow) + 1);
gettimeofday(&t3, NULL);
for (i = 0; i < LOOPS; i++)
native_wide++;
gettimeofday(&t4, NULL);
for (i = 0; i < LOOPS; i++)
wide = bswap_64(bswap_64(wide) + 1);
gettimeofday(&t5, NULL);
printf("long: %9lld us\n", delta(&t1, &t2));
printf("we32: %9lld us\n", delta(&t2, &t3));
printf("u64: %9lld us\n", delta(&t3, &t4));
printf("we64: %9lld us\n", delta(&t4, &t5));
printf("loops: %9d\n", LOOPS);
return 0;
}
Four loops doing the same increment with different data types: long,
u64, we32 (wrong-endian) and we64. Compile with _no_ optimizations.
Results on my i386 notebook:
long: 453953 us
we32: 880273 us
u64: 504214 us
we64: 2259953 us
loops: 100000000
Or thereabouts, not completely stable. Increasing the data width is 10%
slower, 32bit endianness conversions is 2x slower, 64bit conversion is
5x slower.
However, even the we64 loop still munches through 353MB/s (100M
conversions in 2.2s, 8bytes per converion. Double the number if you
count both conversion to/from wrong endianness). Elsewhere in this
thread someone claimed the filesystem peaks out at 13MB/s. One might
further note that only filesystem metadata has to go through endianness
conversion, so on this particular machine it is completely lost in the
noise.
Feel free to run the program on any machine you care about. If you get
numbers to back up your position, I'm willing to be convinced. Until
then, I consider the alleged overhead of endianness conversion a prime
example of premature optimization.
Jörn
--
Joern's library part 7:
http://www.usenix.org/publications/library/proceedings/neworl/full_papers/mckusick.a
next prev parent reply other threads:[~2009-06-22 21:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-13 13:21 [PATCH 06/14] Pramfs: Include files Marco
2009-06-13 14:04 ` Sam Ravnborg
2009-06-13 22:59 ` Arnd Bergmann
2009-06-14 7:15 ` Marco
2009-06-21 17:07 ` Marco
2009-06-21 20:22 ` Arnd Bergmann
2009-06-22 6:23 ` Marco Stornelli
2009-06-22 11:17 ` Arnd Bergmann
2009-06-22 18:05 ` Marco
2009-06-22 18:33 ` Arnd Bergmann
2009-06-22 19:31 ` Chris Simmonds
2009-06-22 20:30 ` Sam Ravnborg
2009-06-22 22:00 ` Tim Bird
2009-06-23 4:21 ` Sam Ravnborg
2009-06-23 17:38 ` Marco
2009-06-23 19:26 ` Jörn Engel
2009-06-23 21:15 ` David Woodhouse
2009-06-23 21:55 ` Arnd Bergmann
2009-06-24 6:32 ` Marco Stornelli
2009-06-24 15:30 ` Arnd Bergmann
2009-06-24 16:49 ` Marco
2009-06-22 21:41 ` Jörn Engel [this message]
2009-06-22 22:20 ` David Woodhouse
2009-06-23 5:57 ` Jörn Engel
2009-06-23 8:31 ` David Woodhouse
2009-06-22 23:07 ` Arnd Bergmann
2009-06-23 6:40 ` Marco Stornelli
2009-06-14 7:15 ` Marco
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=20090622214155.GA19332@logfs.org \
--to=joern@logfs.org \
--cc=arnd@arndb.de \
--cc=chris@2net.co.uk \
--cc=linux-embedded@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.stornelli@gmail.com \
--cc=sam@ravnborg.org \
/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;
as well as URLs for NNTP newsgroup(s).