Skip to content

Prefilter based on http.path #339

@Dr-Emann

Description

@Dr-Emann

I've been thinking of a way to speed things up for huge numbers of routes, by finding required prefixes for http.path for each expression, and using them to quickly narrow down the possible set of expressions to try, hopefully by a lot.

e.g. the following expressions:

[1]: net.dst.port == 9000
[2]: http.path ^= "/abc"
[3]: http.path ~ "^/foobar/(.*)$" && net.dst.port < 8000
[4]: http.path ~ "^/abc123" || http.path == "/123/456"
[5]: http.path ~ "^/123" && net.dst.port == 9001

We could preprocess that to have a mapping of possible prefixes to expressions to check:

(note that expression 1 can match regardless of the path, so it must always be considered)

"/abc" => [1, 2]
"/abc123" => [1, 2, 4]
"/foobar/" => [1, 3]
"/123" => [1, 5]
"/123/456" => [1, 4, 5]
otherwise => [1]

(where the longest prefix that is a prefix of the incoming context determines what expressions need to be checked)

This quick prefilter check should be able to reduce the number of required expression checks by quite a lot, with larger numbers of expressions, assuming most expressions are at least partly based on the http.path.

Rust's regex-syntax crate has the ability to extract required literal prefixes, so we can do that check even for regexes.

I've started working on a library to do exactly this, and results so far seem promising.

Is this something that would be interesting to integrate here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions