Skip to content

Warn about unused whitelist options #1469

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

Merged
merged 2 commits into from
Dec 23, 2018
Merged

Warn about unused whitelist options #1469

merged 2 commits into from
Dec 23, 2018

Conversation

sanxiyn
Copy link
Member

@sanxiyn sanxiyn commented Dec 19, 2018

I welcome suggestions on better ways to report warnings.

cc #1055

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

The change looks reasonable to me, but have you done any perf measurements?

This can generally slow down whitelisting and such, since now you need to match every regex instead of stopping at the first that matches.

If not, it may be worth putting this behind a flag, specially given this is mostly a developer-oriented function. I could see this creating spurious warnings if a header on a given platform differs, which would be unfortunate.

@sanxiyn
Copy link
Member Author

sanxiyn commented Dec 19, 2018

Now I measured performance on internal codebase and I couldn't detect any change, but maybe our use cases are too small. Benchmark suggestions are welcome.

Use case #1

--whitelist-type 1
--whitelist-var 3

old
  time:   770.848 ms.   parse
  time:   632.237 ms.   compute_whitelisted_and_codegen_items
new
  time:   762.946 ms.   parse
  time:   629.872 ms.   compute_whitelisted_and_codegen_items
Use case #2

--whitelist-function 6
--whitelist-type 5
--whitelist-var 1

old
  time:   878.813 ms.   parse
  time:   743.636 ms.   compute_whitelisted_and_codegen_items
new
  time:   881.604 ms.   parse
  time:   726.318 ms.   compute_whitelisted_and_codegen_items

@emilio
Copy link
Contributor

emilio commented Dec 19, 2018

How many regexes are you using in your codebase? In Gecko we use quite a lot of them, see all the lists in:

https://searchfox.org/mozilla-central/source/layout/style/ServoBindings.toml

I still think a configuration option for this would be useful, because it wouldn't be great to spam other developers about warnings that they don't know how to fix, or platform-dependent stuff.

It'd be great if you could do that but otherwise let me know and I'll try to take some time to make it happen as a followup to this PR before the next release.

@sanxiyn
Copy link
Member Author

sanxiyn commented Dec 19, 2018

I already gave how many regexes we use. My understanding of RegexSet implementation is that slowdown happens only if multiple regexes actually match, and that doesn't seem to happen in Gecko, and I expect such cases to be rare.

I think it is very desirable to have this on by default, like Rust's unused warnings. I expect it won't be used in practice if it is not on by default. If it isn't too much trouble, can you run the benchmark for Gecko's use case?

I am uninterested in putting this behind a flag, so I appreciate your offer of a followup. Thanks.

@emilio
Copy link
Contributor

emilio commented Dec 23, 2018

Alright, this works for now, sorry for the lag (Christmas).

Will followup with the option, thank you for the patch! I agree this is useful :)

@emilio emilio merged commit d7dc508 into rust-lang:master Dec 23, 2018
emilio added a commit to emilio/rust-bindgen that referenced this pull request Dec 23, 2018
emilio added a commit that referenced this pull request Dec 23, 2018
Allow to turn off the matches recording introduced in #1469.
@sanxiyn sanxiyn deleted the warn-unused-option branch December 24, 2018 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants