Allow prefiltering based on string fields#341
Conversation
…s we can't prefilter
|
This should be effective. However, I need to find a more representative test suite to verify. Working on it |
|
Test results show high confidence in the improvement. I used GitHub OpenAPI spec and random requests as the test scenario. It shows a slight, but statistically significant improvement in throughput for a constant config(which is kind of expected as cache plays a role in this case); and it shows great improvement in P99 (tail latency) for config changes(route configuring during the tests). |
What does "random requests" mean in this case? Totally random urls, or urls with a random component (/users/{uuid}) (cache wouldn't work in that case)? Or maybe random choices from a set of matching urls? |
URL towards random valid APIs, with random valid parameters. |
|
Lax Max is highly dominated by randomness. Lat P99 and P90 are better indicators for tail latencies. |
|
I wonder how CPU usage is affected, as well. The Kong blog has said:
|
The recorded CPU usage shows 100% utilization. The test is CPU-bound, thus it's already reflected in the throughput metrics. |
Oyami-Srk
left a comment
There was a problem hiding this comment.
Overall LGTM. Could you please extend the existing tests to use enable_prefilter?
Oyami-Srk
left a comment
There was a problem hiding this comment.
LGTM, still need some review and decision from the Kong 3 team. cc @michaelxiong-byte


Closes #339
Fixes #338
Note, this requires calling the
enable_prefiltermethod, otherwise nothing changes.In the case where most matches can be filtered out based on prefixes, it can greatly speed up matching by quickly eliminating large swaths of possible expressions.
I believe most of the time, the
http.pathfield will be ideal for this filtering, where most of the time, looking at the prefix of the value can narrow down matching to just a small number of possible matches.It makes building the router a bit slower
But it can greatly decrease the cost of matching on all but the very first few expressions: