Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(db) improve kong startup time by reusing luasocket on kong.init #4178

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ function Kong.init()
end
--]]

assert(db:connect())
assert(db.plugins:check_db_against_config(config.loaded_plugins))

-- LEGACY
Expand Down Expand Up @@ -344,19 +345,19 @@ function Kong.init()
sort_plugins_for_execution(config, db, loaded_plugins)

local err
plugins_map_semaphore, err = semaphore.new()
plugins_map_semaphore, err = semaphore.new(1) -- 1 = treat this as a mutex
if not plugins_map_semaphore then
error("failed to create plugins map semaphore: " .. err)
end

plugins_map_semaphore:post(1) -- one resource, treat this as a mutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why this change? Seems unrelated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@p0pr0ck5 nothing, just a small cleanup as I was touching code close to it. Not a big deal to include or remove the change.


local _, err = build_plugins_map(db, "init")
if err then
error("error building initial plugins map: ", err)
end

assert(runloop.build_router(db, "init"))

assert(db:close())
end


Expand Down