python-iptables icon indicating copy to clipboard operation
python-iptables copied to clipboard

Speed up code for arm architecture when creating new rules

Open jkklemm opened this issue 2 years ago • 4 comments

Since the arm architecture is slow to always lookup the tables, the creation of many rules with standard targets like Accept or Reject can slow down the creation of firewall rules. For this reason, a dictionary is used to check available tables and standard targets are not check if they are a chain. This code can halve the execution time on an Arm architectures if many firewall rules are created.

jkklemm avatar Oct 31 '23 08:10 jkklemm

Since the arm architecture is slow to always lookup the tables, the creation of many rules with standard targets like Accept or Reject can slow down the creation of firewall rules. For this reason, a dictionary is used to check available tables and standard targets are not check if they are a chain. This code can halve the execution time on an Arm architectures if many firewall rules are created.

Sorry, this escaped my attention. If you still would like to merge it, please rebase it on current master and I'm happy to take a look.

ldx avatar Feb 19 '25 03:02 ldx

I updated the branch with a rebase. Can you have a look at it?

jkklemm avatar Mar 04 '25 10:03 jkklemm

I updated the branch with a rebase. Can you have a look at it?

I think this is a great idea if this gives a speed bump.

That being said, I'd much rather implement this caching via something like a static class field instead of a global variable. Any chance you can refactor this?

ldx avatar Mar 06 '25 15:03 ldx

Thanks for your hint. In my new commit, I moved the variable to a static class variable.

jkklemm avatar Mar 07 '25 20:03 jkklemm

@ldx What has to be changed to merge this improvement?

jkklemm avatar Apr 05 '25 06:04 jkklemm

@jkklemm merged, thank you for your patience!

ldx avatar Apr 06 '25 21:04 ldx