Place all long jumps in one pass over the flowgraph - #1718
Conversation
|
Thank you for preparing this change. The commit message conceptually makes sense. The comment before the function makes sense except "A pass that marked something computes offsets that are too small, so a later pass can find more branches, but in practice only a few passes are needed." — this would need a bit more context or rewording to be comprehensible. The substantial part of the code changes looks roughly consistent with the comments, but I am not ready to reason whether the modified code would correctly handle all input in all scenarios and edge cases. Unfortunately, there is no direct coverage of As far as I understand, that would be generally difficult because it would require serialisation of graphs that are the input, the output and the intermediate data within iterations and recursions. However, in this specific case what |
A branch whose target is more than 255 instructions away needs an extra BPF_JA, and reserving room for one means laying the program out again. convert_code_r() returned on the first such branch it found, so a program needing N long jumps took N passes over the whole flowgraph to place them. That is most of the time spent compiling a filter with a few hundred "or"ed host/port pairs, with or without the optimizer. Mark them all in a pass instead. A long jump only ever makes the program longer, so a branch that does not fit now will not fit in a later pass either. The emitted BPF program is the same as before.
2efa1be to
a78bc05
Compare
|
I updated the message a bit. Let me know what coverage test do you wish to have. If you want to implement, I can definitely wait. |
|
Thank you, let me have a look later, I am currently busy with other work. |
A branch whose target is more than 255 instructions away needs an extra
BPF_JA, and reserving room for one means laying the program out again.convert_code_r()returned on the first such branch it found, so a program needing N long jumps took N passes over the whole flowgraph to place them. That is most of the time spent compiling a filter with a few hundred "or"ed host/port pairs, with or without the optimizer.Attempt to fix #1255.