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

Use pointer for arg key in cache key #553

Merged
merged 2 commits into from
Dec 27, 2022

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Dec 26, 2022

It does happen to work and enables TinyGo to work well

See tinygo-org/tinygo#3354 for context

I found that TinyGo does not handle map keys with embedded variable-length fields (basically just string I guess) well, converting to interface and using reflection, which causes allocations and general slowness.

The arg key string coincidentally has a stable pointer for our purposes here...so we can use it.

This is an alternative to #552 but is very hacky. If it seems like too much, we can give up on the cache for now. But I do think the cache is important for performance so maybe we can live with it. I would be surprised if FTW were to pass in the future if a bug was caused by the pointer stability property not being valid anymore, so that safety measure is there, I guess.

@anuraaga anuraaga requested a review from a team as a code owner December 26, 2022 05:56
@anuraaga anuraaga changed the title Use pointer for arg key in cache key since it does work and enables T… Use pointer for arg key in cache key since it does happen to work and enables T… Dec 26, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2022

Codecov Report

Base: 78.50% // Head: 78.51% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (bbd8913) compared to base (a40315b).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           v3/dev     #553   +/-   ##
=======================================
  Coverage   78.50%   78.51%           
=======================================
  Files         145      145           
  Lines        6955     6958    +3     
=======================================
+ Hits         5460     5463    +3     
  Misses       1263     1263           
  Partials      232      232           
Flag Coverage Δ
default 73.73% <100.00%> (+0.01%) ⬆️
examples 27.47% <100.00%> (+0.03%) ⬆️
ftw 56.81% <100.00%> (+0.01%) ⬆️
tinygo 71.83% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
internal/corazawaf/rulegroup.go 94.18% <ø> (ø)
internal/corazawaf/rule.go 94.67% <100.00%> (+0.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@anuraaga anuraaga changed the title Use pointer for arg key in cache key since it does happen to work and enables T… Use pointer for arg key in cache key Dec 26, 2022
@jcchavezs
Copy link
Member

LGTM, anyways we can change it any moment as this is internal.

@anuraaga
Copy link
Contributor Author

Cool, then need approval to merge

Copy link
Member

@jptosso jptosso left a comment

Choose a reason for hiding this comment

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

Lgtm

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