-
-
Notifications
You must be signed in to change notification settings - Fork 261
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
[Question] Storing parse
result to avoid reparsing? (async related)
#472
Comments
Use in |
Thank you very much! A pity that |
Generally pinning the task to a single thread is very cumbersome or not possible ( Pinning a normally spawned task to a single thread is not possible because this feature is fundamentally incompatible with the |
For completeness, follow up on this !Send !Sync aspect: https://users.rust-lang.org/t/how-to-deal-with-external-type-which-is-send-and-sync/47530 Is there any plan to have Pairs at least |
How about adding an optional feature to turn all the |
parse
result to avoid reparsing?parse
result to avoid reparsing? (async related)
The main issue with such is that it's not really a "strictly additive" feature. Additionally, it's not really possible to be generic between That said, I've primarily been working with Rowan recently, which uses Arc trees rather than Rc, so I do agree that being able to share the parse between threads is useful. (Actually, Rowan uses an Arc for the tree structure itself, but Rc for traversal of the tree, so it's sort of a hybrid approach.) |
That's why I proposed a feature, we could do something like: #[cfg(not(feature = "sync-send"))]
type RefCounted<T> = std::rc::Rc<T>;
#[cfg(feature = "sync-send")]
type RefCounted<T> = std::sync::Arc<T>; and replace every occurence of I wrote a proof of concept here and it seems to be a drop-in replacement. The only issue I found was that in the docs |
The problem is the "purely additive" requirement for features. Sure, a feature flag could add the "feature" of send/sync for the |
I don't follow: if the feature flag is not in default flags, we stay like today, don't we? with @SkiFire13 prototype, we pay for Arc only if we opt-in send-sync feature in our Cargo.toml, or am I missing something? |
Features are unified accross the entire dependency tree. Let's say you use both tera and nalgebra, both of which use pest. Now you use pest directly, and enable the pairs-are-sync feature. Tera and nalgebra also use pest, and there's a single version of pest compiled into your binary. Both tera and nalgebra will be slower to manipulate pairs, as they are using atomic operations, even though both of those libraries didn't enable the feature and are developed to not need it. If anyone in the dependency tree activates a feature, it's enabled for everyone. This is even more insidious if, say, a test dependency is the only one that enables the feature, as now you're paying for it without even benefiting from it anywhere. It's the same reason you shouldn't use mutually exclusive cargo features; features are intended to be strictly additive, because once they're on they're on for everyone. |
Oh I understand better now! What about another module
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I'd like to store the
Pairs<>
in order to avoid reparsing of the same expression and cloning it before reevaluate it usingPrecClimber
.I have two concerns with that:
Thanks!
The text was updated successfully, but these errors were encountered: