forked from api7/lua-resty-radixtree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: make inserting host match route several times faster (api7#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.
- Loading branch information
1 parent
f68d981
commit 7e279b0
Showing
3 changed files
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters