Skip to contentSkip to conversation

seq_file: delete small-value optimization

PATCH Alexey Dobriyan 2 participants 2 messages May 17, 2017

lore
Share & tools
lore
#0 lore raw
Quoted 10 lines

Joe Perches wrote:

Quoted 2 lines · Alexey Dobriyan

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.

#1 lore raw
Quoted 6 lines · Alexey Dobriyan
Quoted 6 lines

Joe Perches wrote:

Quoted 2 lines · Alexey Dobriyan

num_to_str() optimizes printing small integers [0..9], so the same check higher in callchain is unnecessary.

Quoted 7 lines
Quoted 4 lines

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?