-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
refactor: dynamic dispatch async commands #13464
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
Open
Legend-Master
wants to merge
9
commits into
tauri-apps:dev
Choose a base branch
from
Legend-Master:dynamic-dispatch-async-commands
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
07615f0
Dynamic dispatch async commands
Legend-Master e2f24f6
format
Legend-Master de15f05
Preserve `'static`
Legend-Master 5f817b9
Use a inner function instead
Legend-Master 0fb22eb
Only do it for dev for now
Legend-Master d4fe467
Add change file
Legend-Master 549f319
Merge branch 'dev' into dynamic-dispatch-async-commands
Legend-Master 5a64b09
Tag respond_async_serialized_dyn with debug
Legend-Master 097c8d5
Merge remote-tracking branch 'upstream/dev' into dynamic-dispatch-asy…
Legend-Master File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Considering that
respond_async_serialized
is apub
API, isn't this a BREAKING CHANGE?In my opinion, having different signatures in debug and release modes would be confusing.
Not sure if I am correctly: if we only pass in
Box::pin(...) as Pin<Box<dyn ...>>
, then only a single template instantiation ofrespond_async_serialized<Pin<Box<dyn ...>>>
will occur, which is effectively the same as changing the signature toPin<Box<dyn ...>>
, right?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 believe this part was marked as unstable?
That's true though, I feel like the performance hit probably won't be a problem considering this is only a pretty small part of the call chain anyways
I believe the box itself will create a new generic variation for every closure, so this probably won't work
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.
Not entirely sure if this was marked as unstable or not, will double check that tomorrow, but since we manage it through macros, it should be easy to add a new function
Uh oh!
There was an error while loading. Please reload this page.
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.
it's probably meant to be unstable but we only communicated that on the "parent"
Invoke
struct.honestly though? in my opinion marking anything
pub
in our main tauri crate as unstable only via a doc comment is bullshit. Ideally unstable APIs should not be public, or clearly unstable (feature flag, or in anunstable
module path idk) but that's a discussion for later i guess.Since we're working on v3 i think marking it as deprecated would be the more sensible choice here.
"working" as in praying it will somehow appear out of nowhereThere 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 am already directly using
Invoke
downstream (in pytauri), so I always hope these APIs change as little as possible (v3
) 😂Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah, I think so after checking
To be fair though, some of the things like
generate_handler!
andgenerate_context!
and the related code are impossible to be stable and they still have to be publicNormally, users won't use them directly so it's fine to break, but it's probably a problem for the library authors (I pinned the tauri version in
tauri-runtime-verso
, and also we can see the impact onpytauri
as well)I have tried to make a inner private function so the public API won't change from this, and it seems to only produce slightly more LLVM IR than doing it from the macro, pushed it
Thanks for the heads up @WSH032 about avoiding this breaking change!
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.
And the question is now, do we want to use this for both the debug build and the release build, or do we only do this in debug build for now, since this is done with a private inner function, we should be able to change this without any breakages
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 just tested this
Box::pin(...) as Pin<Box<dyn ...>>
, and from the assembly output it does seem that only one instantiation ofrespond_async_serialized<Pin<Box<dyn ...>>>
occurs: https://godbolt.org/z/9sMMqdo1oI think I'll use
#[doc(hide)]
to hide them.I think everyone has their own preferences. Personally, I don't care about code bloat, so I would prefer using
dyn
in debug mode to speed up development, and usingimpl
generics in release mode to optimize performance.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.
Interesting, we could try that as well (I do want to avoid thing inside the macro in general though, so if the inner function method works, I might prefer that one)
We can't hide the top level macros like
generate_handler!
, but we probably can hide the other ones, but to be fair, they still show up in IDEs so I'm not sure how effective would this beGood to know, I feel like this probably won't be a problem in terms of performance since the overhead of other things will heavily out weight the cost of this, but I'm fine with keeping it the same in release mode for now
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.
Well there are exceptions to everything, it just shouldn't be the standard.