This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC] strcpy optimizations
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: andi at firstfloor dot org
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 29 Jan 2013 21:15:42 +0100
- Subject: [RFC] strcpy optimizations
Hi, I have several questions about strcpy.
First question: I need to know if it is safe for example to use pblendvb
on high 8 bytes while other thread modifies lower 8 bytes?
If I could do that then I could create faster strcpy.
As most of time argument is less than 80 I would use it to write
page at time.
If not then I would use different strategy.
Second question:
Related is that I looked at strcpy implementations and possible improvement
is handle differently copying 1-15 bytes. I put microbenchmark at
kam.mff.cuni.cz/~ondra/strcpy_tail.tar.bz2
It consists from three variants
rep.s - using rep stosb
table.s - current glibc
branch.s - my improvement.
My benchmark branch is fastest(tested on core2,i7,phenomII,fx10).
As it is also smaller fact that I do test with everything in L1 cache
would only help. Did I miss anything?
Third question is what usage is worth optimizing. When I looked how
firefox(biggest usage on my computer) most of calls are used to copy
a english dictonary. I do not know what is used strncpy in font
configuration which also takes considerable portion, typical usage is
following:
Breakpoint 1, strncpy (x=0x7fffffff72e2 "primary\tGB2312.1980-0:GL\n",
y=0x7ffff6b49004 "imary\tGB2312.1980-0:GL\n", n=1) at hooks.c:228
228 START_MEASURE(strcpy);
(gdb)
Continuing.
Breakpoint 1, strncpy (x=0x7fffffff72e3 "rimary\tGB2312.1980-0:GL\n",
y=0x7ffff6b49005 "mary\tGB2312.1980-0:GL\n", n=1) at hooks.c:228
228 START_MEASURE(strcpy);
(gdb)
Continuing.
Breakpoint 1, strncpy (x=0x7fffffff72e4 "imary\tGB2312.1980-0:GL\n",
y=0x7ffff6b49006 "ary\tGB2312.1980-0:GL\n", n=1) at hooks.c:228
228 START_MEASURE(strcpy);
(gdb)
Continuing.
Breakpoint 1, strncpy (x=0x7fffffff72e5 "mary\tGB2312.1980-0:GL\n",
y=0x7ffff6b49007 "ry\tGB2312.1980-0:GL\n", n=1) at hooks.c:228
228 START_MEASURE(strcpy);
(gdb)
Continuing.
Breakpoint 1, strncpy (x=0x7fffffff72e6 "ary\tGB2312.1980-0:GL\n",
y=0x7ffff6b49008 "y\tGB2312.1980-0:GL\n", n=1) at hooks.c:228
228 START_MEASURE(strcpy);
(gdb)
Continuing.
Breakpoint 1, strncpy (x=0x7fffffff72e0 "primary", y=0x7ffff6b4900a
"GB2312.1980-0:GL\n", n=1) at hooks.c:228
228 START_MEASURE(strcpy);
(gdb) bt
#0 strncpy (x=0x7fffffff72e0 "primary", y=0x7ffff6b4900a
"GB2312.1980-0:GL\n", n=1) at hooks.c:228
#1 0x00007ffff14ab7d4 in ?? () from /usr/lib/libX11.so.6
#2 0x00007ffff14ac52b in ?? () from /usr/lib/libX11.so.6
#3 0x00007ffff14aca7c in _XlcCreateLocaleDataBase () from
/usr/lib/libX11.so.6
#4 0x00007ffff14b0d88 in ?? () from /usr/lib/libX11.so.6
#5 0x00007ffff14b0243 in ?? () from /usr/lib/libX11.so.6
#6 0x00007ffff14b0ac6 in _XlcCreateLC () from /usr/lib/libX11.so.6
#7 0x00007ffff14d2d20 in _XlcUtf8Loader () from /usr/lib/libX11.so.6
#8 0x00007ffff14b84d6 in _XOpenLC () from /usr/lib/libX11.so.6
#9 0x00007ffff14b8618 in _XlcCurrentLC () from /usr/lib/libX11.so.6
#10 0x00007ffff14b8649 in XSupportsLocale () from /usr/lib/libX11.so.6
#11 0x00007fffef0e4306 in ?? () from
/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
#12 0x00007fffef0e8ca9 in ?? () from
/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
#13 0x00007fffef6975ea in ?? () from
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#14 0x00007ffff00698b8 in g_option_context_parse () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007fffef6978a0 in gtk_parse_args () from
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#16 0x00007ffff396b54b in XRE_main () from
/usr/lib/xulrunner-1.9.1/libxul.so
#17 0x0000000000402465 in ?? ()
#18 0x00007ffff70daead in __libc_start_main (main=<value optimized out>,
argc=<value optimized out>, ubp_av=<value optimized out>,
init=<value optimized out>, fini=<value optimized out>,
rtld_fini=<value optimized out>, stack_end=0x7fffffffdb68) at
libc-start.c:228