-
Notifications
You must be signed in to change notification settings - Fork 101
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
Cache identifier #904
Cache identifier #904
Conversation
ccf702d
to
57aeebf
Compare
workflow-core/src/commonMain/kotlin/com/squareup/workflow1/WorkflowIdentifier.kt
Show resolved
Hide resolved
If this pans out it will be a breaking change in a non-experimental interface, right? Wondering about proper SemVer treatment, wondering if we should provide a default implementation on the Workflow interface with a warning that it will be removed… All of which is well out of scope for the PR, no reason to overthink things before we know it's a win. |
workflow-core/src/commonMain/kotlin/com/squareup/workflow1/Workflow.kt
Outdated
Show resolved
Hide resolved
workflow-core/src/commonMain/kotlin/com/squareup/workflow1/StatefulWorkflow.kt
Outdated
Show resolved
Hide resolved
We could get around this with a bit more syntactic sugar. We could make the caching property |
cca6c00
to
695e56d
Compare
695e56d
to
567b575
Compare
DNM: Note that we do not want to merge this until we determine its performance impact. |
567b575
to
ab2a993
Compare
Nvm this. We do it with an extension interface |
Note that in our testing we did see a 28% improvement for the 'worst case' scenarios. No change to the median, but still a net positive. |
Abandoned in favour of #911 |
Avoid the class name lookup which happens on the
identifier
extension property getter each time currently.Instead, when a Workflow is
IdCacheable
(asStatelessWorkflow
andStatefulWorkflow
are) we cache theidentifier
ascachedIdentifier
and inline fetch this in the getter instead of computing it each time. We do this inStatefulWorkflow
andStatelessWorkflow
abstract classes using a lazy delegate that callscomputeIdentifier
(same impl as before). It's lazy in case we are anImpostorWorkflow
and we need ourrealIdentifier
initialized beforecomputeIdentifier
is called.