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(pdk) track the size of the Lua table via local Lua variable inst… #4169

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

moonming
Copy link
Contributor

@moonming moonming commented Jan 8, 2019

…ead of table.insert.

NOTE: Please read the CONTRIBUTING.md guidelines before submitting your patch,
and ensure you followed them all:

https://github.com/Kong/kong/blob/master/CONTRIBUTING.md#contributing

Summary

The table.insert is an O(n) operation due to the lj_tab_len call inside LuaJIT.
We can avoid it in hot loops for better performance.

Full changelog

  • track the size of the Lua table via local Lua variable instead of table.insert.

@CLAassistant
Copy link

CLAassistant commented Jan 8, 2019

CLA assistant check
All committers have signed the CLA.

@thibaultcha
Copy link
Member

Hi!

This is really not a hot code path. We only invoke this function once in the entire lifecycle of Kong (in init_by_lua) here.

@thibaultcha thibaultcha merged commit 250757c into Kong:master Jan 8, 2019
@thibaultcha
Copy link
Member

@moonming Thanks!

@hishamhm hishamhm added this to the 1.0.1 milestone Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants