Messages in this thread | | | Date | Tue, 27 Jul 1999 19:24:06 +0200 | From | Artur Skawina <> | Subject | Re: Faster strlen |
| |
Alexander Maryanchick wrote: > > Here is a critical piece of their 'strlen' code: > > mov eax,dword ptr [ecx] ; read 4 bytes > mov edx,7efefeffh > add edx,eax > xor eax,-1 > xor eax,edx > add ecx,4 > test eax,81010100h > je short main_loop > ; found zero byte in the loop > > On Pentiums this sadistic code is 4 times faster that our :-(.
> So, some parts of Linux kernel may be optimized...
for this case something like the followind diff solves the problem nicely, at least for recent compilers (it may have to be wrapped with gcc-version conditionals). [sorry for no offsets, but i've extracted this from many other changes to string.h; I will have to clean this up before making the rest available] The difference in speed for kernel vs gcc2.95 strlen can be as bad as (timed for rather long strings - not the best benchmark; on a celeron)
318011 574120 574118 57076 41560 : ffff strlen_builtin 1003034 1810793 1810791 179996 130600 : ffff strlen_kernel
diff -urNp --exclude-from /usr/src/lkdontdiff /img/linux-2.3.12p5/include/asm-i386/string.h linux-as/include/asm-i386/string.h --- /img/linux-2.3.12p5/include/asm-i386/string.h Sat May 1 16:36:31 1999 +++ linux-as/include/asm-i386/string.h Mon Jul 26 10:52:25 1999 :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff)); return __res; } +#define strlen __builtin_strlen extern inline void * __memcpy(void * to, const void * from, size_t n) {
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |