Re: [PATCH] small update for strlen, strnlen, use less cpu instructions

From: Mihai DonÈu
Date: Tue Jun 16 2015 - 06:04:08 EST


On Tue, 16 Jun 2015 04:40:55 -0500 Orestes Leal Rodriguez wrote:
> very small update to strlen and strnlen that now use less cpu
> instructions by using a counter to avoid the memory addresses
> substraction to find the length of the string.

Nice. :-)

Performance counter stats for './strnlen-new':

3.602591 task-clock (msec) # 0.836 CPUs utilized
4 context-switches # 0.001 M/sec
2 cpu-migrations # 0.555 K/sec
48 page-faults # 0.013 M/sec
9,607,307 cycles # 2.667 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
23,612,424 instructions # 2.46 insns per cycle
9,121,754 branches # 2531.998 M/sec
5,409 branch-misses # 0.06% of all branches

0.004311477 seconds time elapsed


Performance counter stats for './strnlen-old':

3.181354 task-clock (msec) # 0.930 CPUs utilized
1 context-switches # 0.314 K/sec
1 cpu-migrations # 0.314 K/sec
47 page-faults # 0.015 M/sec
8,558,129 cycles # 2.690 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
23,577,237 instructions # 2.75 insns per cycle
9,114,760 branches # 2865.057 M/sec
4,298 branch-misses # 0.05% of all branches

0.003419085 seconds time elapsed

However, you will need to create a proper patch:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/SubmittingPatches

--
Mihai DonÈu
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/