* Re: [PATCH] seq_file: delete small-value optimization
@ 2017-05-17 10:33 Alexey Dobriyan
2017-05-17 23:25 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2017-05-17 10:33 UTC (permalink / raw)
To: joe; +Cc: akpm, linux-kernel
> Joe Perches wrote:
>
> On Tue, 2017-05-16 at 23:42 +0300, Alexey Dobriyan wrote:
> > num_to_str() optimizes printing small integers [0..9], so the same
> > check higher in callchain is unnecessary.
>
> Doesn't the optimization exists for the frequent use of 0
> in seq output?
>
> These seq_put_decimal calls are now slightly more expensive.
That additional CALL instruction is hardly measurable so you're adding
branch to skip branch in the next function.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] seq_file: delete small-value optimization
2017-05-17 10:33 [PATCH] seq_file: delete small-value optimization Alexey Dobriyan
@ 2017-05-17 23:25 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2017-05-17 23:25 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: akpm, linux-kernel
On Wed, 2017-05-17 at 13:33 +0300, Alexey Dobriyan wrote:
> > Joe Perches wrote:
> >
> > On Tue, 2017-05-16 at 23:42 +0300, Alexey Dobriyan wrote:
> > > num_to_str() optimizes printing small integers [0..9], so the same
> > > check higher in callchain is unnecessary.
> >
> > Doesn't the optimization exists for the frequent use of 0
> > in seq output?
> >
> > These seq_put_decimal calls are now slightly more expensive.
>
> That additional CALL instruction is hardly measurable so you're adding
> branch to skip branch in the next function.
It's not the call instruction.
num_to_str pushes the value first to stack
and then sets up a loop to copy those chars
to buffer.
The current code immediately pushes to buffer.
It's a fair amount of overhead.
Have you measured it?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] seq_file: delete small-value optimization
2017-05-16 20:42 Alexey Dobriyan
@ 2017-05-17 7:11 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2017-05-17 7:11 UTC (permalink / raw)
To: Alexey Dobriyan, akpm; +Cc: linux-kernel
On Tue, 2017-05-16 at 23:42 +0300, Alexey Dobriyan wrote:
> num_to_str() optimizes printing small integers [0..9], so the same
> check higher in callchain is unnecessary.
Doesn't the optimization exists for the frequent use of 0
in seq output?
These seq_put_decimal calls are now slightly more expensive.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] seq_file: delete small-value optimization
@ 2017-05-16 20:42 Alexey Dobriyan
2017-05-17 7:11 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2017-05-16 20:42 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, joe
num_to_str() optimizes printing small integers [0..9], so the same
check higher in callchain is unnecessary.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/seq_file.c | 10 ----------
1 file changed, 10 deletions(-)
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -694,11 +694,6 @@ void seq_put_decimal_ull(struct seq_file *m, const char *delimiter,
if (m->count + 1 >= m->size)
goto overflow;
- if (num < 10) {
- m->buf[m->count++] = num + '0';
- return;
- }
-
len = num_to_str(m->buf + m->count, m->size - m->count, num);
if (!len)
goto overflow;
@@ -733,11 +728,6 @@ void seq_put_decimal_ll(struct seq_file *m, const char *delimiter, long long num
num = -num;
}
- if (num < 10) {
- m->buf[m->count++] = num + '0';
- return;
- }
-
len = num_to_str(m->buf + m->count, m->size - m->count, num);
if (!len)
goto overflow;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-17 23:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 10:33 [PATCH] seq_file: delete small-value optimization Alexey Dobriyan
2017-05-17 23:25 ` Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2017-05-16 20:42 Alexey Dobriyan
2017-05-17 7:11 ` Joe Perches
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).