public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Douglas W Jones <jones@cs.uiowa.edu>,
	Michal Nazarewicz <mnazarewicz@google.com>
Subject: [PATCH 0/1] vsprintf: optimize decimal conversion (again)
Date: Mon, 26 Mar 2012 20:47:17 +0200	[thread overview]
Message-ID: <201203262047.17865.vda.linux@googlemail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]

Hi Andrew,

Can you take this patch into -mm?

Michal, Jones - can you review the code?

Sometime ago, Michal Nazarewicz <mina86@mina86.com> optimized our
(already fast) decimal-to-string conversion even further.
Somehow this effort did not reach the kernel.

Here is a new iteration of his code.

Optimizations and patch follow in next email.

Please find test programs attached.

32-bit test programs were built using gcc 4.6.2
64-bit test programs were built using gcc 4.2.1
Command line: gcc --static [-m32] -O2 -Wall test_{org,new}.c

Sizes:
org32.o: 2850 bytes
new32.o: 2858 bytes
org64.o: 2155 bytes
new64.o: 2283 bytes

Correctness: I tested first and last 40 billion values from [0, 2^64-1] range,
they all produced correct result.

Speed:
I measured how many thousands of conversions per second are done, for several values
(it takes different amount of time to convert, say, 123 and 2^64-1 to their
string representations).
Format of data below: VALUE:THOUSANDS_OF_CONVS_PER_SEC.

Intel Core i7 2.7GHz:
org32: 8:46852 123:39252 123456:23992 12345678:21992 123456789:21048 2^32-1:20424 2^64-1:10216
new32: 8:55300 123:43208 123456:34456 12345678:31272 123456789:23584 2^32-1:23568 2^64-1:16720

AMD Phenom II X4 2.4GHz:
org32: 8:29244 123:23988 123456:13792 12345678:12056 123456789:11368 2^32-1:10804 2^64-1:5224
new32: 8:38040 123:30356 123456:22832 12345678:20676 123456789:13556 2^32-1:13472 2^64-1:9228

org64: 8:38664 123:29256 123456:19188 12345678:16320 123456789:15380 2^32-1:14896 2^64-1:7864
new64: 8:42664 123:31660 123456:21632 12345678:19220 123456789:20880 2^32-1:17580 2^64-1:9596

Summary: in all cases new code is faster than old one, in many cases by 30%,
in few cases by more than 50% (for example, on x86-32, conversion of num=12345678).
Code growth is ~0 in 32-bit case and ~130 bytes in 64-bit case.

-- 
vda

[-- Attachment #2: test_dec_conversion.tar.gz --]
[-- Type: application/x-tgz, Size: 5949 bytes --]

             reply	other threads:[~2012-03-26 18:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 18:47 Denys Vlasenko [this message]
2012-03-26 18:51 ` [PATCH 1/1] vsprintf: optimize decimal conversion (again) Denys Vlasenko
2012-03-26 19:51   ` Andrew Morton
2012-03-26 19:56     ` Denys Vlasenko
2012-03-26 20:13       ` Andrew Morton
2012-03-26 20:18         ` Geert Uytterhoeven
2012-03-26 23:18           ` Denys Vlasenko
2012-03-27  0:30             ` Denys Vlasenko
2012-03-27  3:49             ` H. Peter Anvin
2012-03-26 20:20         ` H. Peter Anvin
2012-03-27 17:12           ` Michal Nazarewicz
2012-03-27 17:17             ` H. Peter Anvin
2012-03-27  0:26         ` Denys Vlasenko
2012-03-27 12:08 ` [PATCH 0/1] " roma1390
2012-03-27 15:32   ` Denys Vlasenko
2012-03-27 15:42   ` Denys Vlasenko
2012-03-28  5:56     ` roma1390
2012-03-28 10:13       ` Denys Vlasenko
2012-03-28 10:24         ` roma1390
2012-03-28 10:33           ` Denys Vlasenko
2012-03-28 10:39             ` roma1390
2012-03-28 11:20               ` Denys Vlasenko
2012-03-29 10:35             ` Denys Vlasenko
2012-03-28 10:31         ` roma1390
2012-03-28 11:23           ` Denys Vlasenko
2012-03-29  5:23             ` roma1390
2012-03-29 10:33               ` Denys Vlasenko
2012-03-27 13:49 ` roma1390
2012-03-27 15:33   ` Denys Vlasenko
2012-03-29  5:16     ` roma1390
2012-03-29 10:33       ` Denys Vlasenko

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=201203262047.17865.vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jones@cs.uiowa.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mnazarewicz@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