Skip to content

fix: de-duplicate shm references - #2

Closed
flrgh wants to merge 1 commit into
Kong:masterfrom
flrgh:fix/dedupe-shm-references
Closed

flrgh wants to merge 1 commit into
Kong:masterfrom
flrgh:fix/dedupe-shm-references

Conversation

@flrgh

@flrgh flrgh commented Jul 6, 2022 •

Copy link
Copy Markdown

Store a permanent reference to the lock shm object instead of using the memo table with the lock keys. Reduces the size+churn on the memo table by 50%.

This is greatly optimizes the happy path (when the lock is explicitly unlock()-ed by the caller and not by gc) because no table operations are done during garbage collection in this case. This makes resty.lock much less susceptible to memo table fragmentation.

@flrgh

flrgh commented Jul 6, 2022

Copy link
Copy Markdown
Author

Snagged the bench script from #1 (comment) and ran it on this. Results:

$ resty --http-include lock_include.conf perflock.lua
original: 7.4079999923706
new: 6.9720001220703

@flrgh

flrgh commented Jul 6, 2022

Copy link
Copy Markdown
Author

Results with jit.off(ref_obj); jit.off(unref_obj) in both files:

$ resty --http-include lock_include.conf perflock.lua
original: 14.645999908447
new: 14.079999923706

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.

1 participant