-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
refactor(turbo-tasks): Convert local Vcs to non-local Vcs when returning from task functions #74714
base: bgw/vcarc-uses-operationvc
Are you sure you want to change the base?
refactor(turbo-tasks): Convert local Vcs to non-local Vcs when returning from task functions #74714
Conversation
fn $get_args_fn<$($arg: TaskInput + 'static,)*>(arg: &dyn MagicAny) -> Result<($($arg,)*)> { | ||
match arg.downcast_ref::<($($arg,)*)>() { | ||
Some(($($arg,)*)) => Ok(($($arg.clone(),)*)), | ||
None => { | ||
#[cfg(debug_assertions)] | ||
let context_str = get_debug_downcast_error_msg::<($($arg,)*)>(arg); | ||
#[cfg(not(debug_assertions))] | ||
let context_str = "Invalid argument type"; | ||
|
||
anyhow::bail!(context_str); | ||
} | ||
} | ||
} |
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.
Moved this inside the macro, which lets us deduplicate the .clone()
calls, instead of putting them in each individual trait implementation.
impl<F, Output, Recv, $($arg,)*> TaskFnInputFunctionWithThis<OperationMode, Recv, ($($arg,)*)> for F | ||
where | ||
Recv: Sync + Send + 'static, | ||
$($arg: TaskInput + 'static,)* | ||
F: Fn(OperationVc<Recv>, $($arg,)*) -> Output + Send + Sync + Clone + 'static, | ||
Output: TaskOutput + 'static, | ||
{ | ||
#[allow(non_snake_case)] | ||
fn functor(&self, this: RawVc, arg: &dyn MagicAny) -> Result<NativeTaskFuture> { | ||
let task_fn = self.clone(); | ||
let recv = OperationVc::<Recv>::from(this); | ||
|
||
let ($($arg,)*) = get_args::<($($arg,)*)>(arg)?; | ||
$( | ||
let $arg = $arg.clone(); | ||
)* | ||
|
||
let ($($arg,)*) = $get_args_fn::<$($arg,)*>(arg)?; | ||
Ok(Box::pin(async move { | ||
Output::try_into_raw_vc((task_fn)(recv, $($arg,)*)) | ||
let output = (task_fn)(recv, $($arg,)*); | ||
output_try_into_non_local_raw_vc(output).await | ||
})) | ||
} | ||
} |
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.
I ended up not implementing support for methods with #[turbo_tasks::function(operation)]
, given that there's a limited number of callsites, and dynamic dispatch likely couldn't work with methods taking self: OperationVc
anyways.
Stats from current PRDefault BuildGeneral
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size
Middleware size
Next Runtimes
build cache
Diff detailsDiff for main-HASH.jsDiff too large to display |
fn get_args<T: MagicAny>(arg: &dyn MagicAny) -> Result<&T> { | ||
let value = arg.downcast_ref::<T>(); |
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.
I guess you could have archived the same with:
-fn get_args<T: MagicAny>(arg: &dyn MagicAny) -> Result<&T> {
+fn get_args<T: MagicAny + Clone>(arg: &dyn MagicAny) -> Result<T> {
- let value = arg.downcast_ref::<T>();
+ let value = arg.downcast_ref::<T>().clone();
Since the tuple could be cloned
But not sure...
d2c1eab
to
56c77c9
Compare
110001f
to
1f21777
Compare
Failing test suitesCommit: 0e91d34
Expand output● dynamic-io › should not have route specific errors
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
● dynamic-io › should prerender pages with cached
● dynamic-io › should not prerender pages with uncached
Read more about building and testing Next.js in contributing.md.
Expand output● next.rs api › should allow to write root page to disk
● next.rs api › should allow to write root page to disk
● next.rs api › should allow to write pages edge api to disk
● next.rs api › should allow to write pages Node.js api to disk
● next.rs api › should allow to write app edge page to disk
● next.rs api › should allow to write app edge page to disk
● next.rs api › should allow to write app Node.js page to disk
● next.rs api › should allow to write app Node.js page to disk
● next.rs api › should allow to write pages edge page to disk
● next.rs api › should allow to write pages edge page to disk
● next.rs api › should allow to write pages Node.js page to disk
● next.rs api › should allow to write pages Node.js page to disk
● next.rs api › should allow to write app edge route to disk
● next.rs api › should allow to write app Node.js route to disk
Read more about building and testing Next.js in contributing.md.
Expand output● Conflict between app file and pages file › should show error overlay for /another
● Conflict between app file and pages file › should show error overlay for /
● Conflict between app file and pages file › should error again when there is new conflict
Read more about building and testing Next.js in contributing.md.
Expand output● persistent-caching › should persistent cache loaders
Read more about building and testing Next.js in contributing.md. |
56c77c9
to
3ca36f6
Compare
1f21777
to
1a10536
Compare
3ca36f6
to
d930890
Compare
1a10536
to
59ff3b4
Compare
d930890
to
fc3f3d2
Compare
59ff3b4
to
1713534
Compare
fc3f3d2
to
968aa54
Compare
1713534
to
90c2d5c
Compare
968aa54
to
9585d5e
Compare
90c2d5c
to
fe63d1b
Compare
9585d5e
to
2d433d3
Compare
…ing from task functions
fe63d1b
to
0e91d34
Compare
No description provided.