Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #18881

Closed
Open
Created Apr 24, 2016 by toralf@toralf

speed up is_match() of stem/exit_policy.py

I turns out to me, that the following code snipped

        for conn in connections:
          raddr, rport, lport = conn.remote_address, conn.remote_port, conn.local_port
          if policy.can_exit_to(raddr, rport):
            Curr.setdefault(rport, []).append(str(lport) + ':' + raddr)

takes much longer than expected due to the fact, that policy.can_exit() calls is_match() which itself makes a a lot of checks eg.:

    # validate our input and check if the argument doesn't match our address type

    if address is not None:

For a relay having about 5,000 connections and about 100 ExitPolicy rules thoses checks are repeated 500,000 times w/o too much profit, or ?

I do wonder if is_match() could get a wrapper which just does the given address+port test against the exit policy ?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking