Skip to content

v2.3

Compare
Choose a tag to compare
@membphis membphis released this 17 Sep 06:33
· 50 commits to master since this release
7e279b0
perf: make inserting host match route several times faster (#62)

Previously, `insert_route` will sort the table with `table.sort`.
The `table.sort` is implemented via quick-sort, which is in O(nlogn)
complexity and perform worse when the table is already mostly sorted.

Since we can ensure the table is sorted before inserting, we can
implement a naive insert sort in O(n) complexity to replace `table.sort`.

Via `time resty -I=./lib -I=./deps/share/lua/5.1 benchmark/match-hosts.lua`
I see an impressive time reduction with this optimization.