-
-
Notifications
You must be signed in to change notification settings - Fork 476
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
[RFC] feat(linter): support persisted rule state #5799
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #5799 will not alter performanceComparing Summary
|
ecaa30e
to
e413cad
Compare
a8b8745
to
58cc4f0
Compare
58cc4f0
to
19dce4e
Compare
19dce4e
to
32c4acd
Compare
I haven't delved fully into this but...
Don't do it then! You are the chief of the linter, it's your call. Also, it seems my original issue #5204 which started this all was based on a fundamental misunderstanding (I didn't realize that Side note: What's with the "no hash hasher" crate? This seems quite a weird idea. Maybe I'm missing something, but isn't it a recipe for hashmap collisions?
https://github.com/rust-lang/rustc-hash/blob/eb049a8209f58003957c34477a2d8d2729f6b633/src/lib.rs#L96-L101 That is just 3 CPU ops to hash a |
Apologies for never responding with my thoughts. I do not enjoy writing and my thoughts about it could be quite long :P I'll get them down for you though.
Its a crate that hashes small primitives using the identity function. It's supposed to replace a sparse array. There's a chance for collision if your have duplicate keys. In this case, all rules are guaranteed to have a unique ID, so this won't be a problem. |
You don't need to explain yourself for me. I just wanted to make sure I hadn't pushed you in a direction you didn't really want to go in.
As far as I can see, that's not quite true...
If the keys are So the question isn't "are the keys unique?" but "are the bottom bits of keys unique?" In addition, There will probably be some use cases where the pattern of keys being used may fit well with this scheme (you'd hope so, that crate has 13 million downloads!). But in many cases, it won't - the cost of hashing with a cheap hash function like I see the repo for TLDR: I can't say for sure whether the pattern of keys here is suitable for |
Provides a way for rules to maintain state across invocations of
run
,run_on_symbol
, andrun_once
without forcing those functions to take&mut self
.Note
I really do not like this approach. It's way too loose w.r.t Rust's type checker, and solutions requiring
Any
are red flags to me. I'd much prefer rules to create state ad-hoc inside ofrun_once
and then iterate over nodes themselves.I also didn't test this code at all. For now, this PR is meant to be a conversation starter.