-
Notifications
You must be signed in to change notification settings - Fork 47
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
Support concurrent swc_common
via feature
#250
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
unsafe impl Send for DiagnosticCollector {} | ||
unsafe impl Sync for DiagnosticCollector {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can feature gate these, but without concurrent
, Send
and Sync
are noops:
#[cfg(not(feature = "concurrent"))]
mod single {
pub use once_cell::unsync::{Lazy, OnceCell};
/// Dummy trait because swc_common is in single thread mode.
pub trait Send {}
/// Dummy trait because swc_common is in single thread mode.
pub trait Sync {}
impl<T> Send for T where T: ?Sized {}
impl<T> Sync for T where T: ?Sized {}
pub use std::{
cell::{
Ref as ReadGuard, RefMut as WriteGuard, RefMut as MappedWriteGuard,
RefMut as LockGuard, RefMut as MappedLockGuard,
},
rc::{Rc as Lrc, Weak},
};
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone is using concurrent
then this not being thread safe will cause thread concurrency issues. Probably this will need a thread safe implementation when compiling with concurrent.
@@ -29,6 +29,7 @@ typescript = ["transforms", "swc_ecma_transforms_typescript"] | |||
utils = ["swc_ecma_utils"] | |||
view = ["dprint-swc-ext/view"] | |||
visit = ["swc_ecma_visit", "swc_visit", "swc_visit_macros", "swc_macros_common"] | |||
concurrent = ["swc_common/concurrent"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in #219 (comment) , I'm not sure this is a scenario we want to bother to support.
Do you really need this feature? How much faster have you found it? We've just started using separate threads per file. Maybe in bundling scenarios this is faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. We can add a concurrent
feature here, but no guarantee it's going to work in the future. It might be removed at any time due to the maintenance cost and you might have to contribute fixes to get it working again.
ed4e2dc
to
65651cf
Compare
40bfbc5
to
437ef65
Compare
When using
swc_common
withfeature = ["concurrent"]
,deno_ast
fails to compile.Resolves #219
cc @dsherret