Skip to content

Conversation

@dandavison
Copy link
Contributor

@dandavison dandavison commented Aug 28, 2025

  • Add support for nexus in WorkerTuner and support max_concurrent_nexus_tasks worker config option
  • Add tests for nexus worker concurrency parameters

💥 This is a breaking change: create_composite() has gained a required nexus_supplier parameter.

@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 3 times, most recently from 9720da1 to c9567a6 Compare September 3, 2025 21:15
@dandavison dandavison marked this pull request as ready for review September 3, 2025 21:37
@dandavison dandavison requested a review from a team as a code owner September 3, 2025 21:37
@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch from f9134fe to 189effe Compare September 4, 2025 18:56
@dandavison dandavison marked this pull request as draft September 4, 2025 18:57
cursor[bot]

This comment was marked as outdated.

@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 3 times, most recently from 563f093 to c9c99ea Compare September 5, 2025 01:59
@dandavison dandavison marked this pull request as ready for review September 5, 2025 02:04
@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 2 times, most recently from d551ef2 to ed72439 Compare September 5, 2025 02:14
cursor[bot]

This comment was marked as outdated.

@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 4 times, most recently from fcbb9de to cd8ad93 Compare September 5, 2025 15:01
return temporalio.bridge.worker.FixedSizeSlotSupplier(slot_supplier.num_slots)
elif isinstance(slot_supplier, ResourceBasedSlotSupplier):
min_slots = 5 if kind == "workflow" else 1
max_slots = _DEFAULT_RESOURCE_ACTIVITY_MAX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we're now using the constant for both activities and nexus operation so I renamed it.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only blocking concern is one of backwards compatibility break

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we can't merge this until temporalio/sdk-core#994 is merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right

return ss.num_slots
elif isinstance(ss, ResourceBasedSlotSupplier):
return ss.slot_config.maximum_slots or _DEFAULT_RESOURCE_ACTIVITY_MAX
return self._get_slot_supplier_max(self._get_activity_task_slot_supplier())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_slot_supplier_max is a static call, not sure if self. is the right thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Python allows referencing staticmethods on self but I agree I shouldn't do it and perhaps they could be shadowed by an instance method. Changed.

activity_slots: Optional[int],
local_activity_slots: Optional[int],
) -> "WorkerTuner":
nexus_slots: Optional[int],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This additional required parameter and the additional required parameter on create_composite are technically backwards incompatible. I think tuning is still experimental, but that may only be custom slot suppliers. I think it's worth confirming whether these two static methods are considered GA and if they are, we may need to provide acceptable defaults (here is easy, it can be None, for create_composite, just a fixed size supplier is probably the default but at runtime per call, not global shared). If these are not considered GA, we can just add a 💥 note here and in release notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I've updated the PR to make it backwards compatible. I've made it so that nexus is consistent with the workflow/activity/LA by giving them all defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that can make sense for create_fixed, but made a comment just now concerning create_composite

@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 2 times, most recently from f41641b to bad9bb8 Compare September 8, 2025 15:45
cursor[bot]

This comment was marked as outdated.

@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 5 times, most recently from e5958c9 to 769fd82 Compare September 10, 2025 22:07
)

@staticmethod
def create_composite(
Copy link
Member

@cretz cretz Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we explicitly designed this to require people to provide at least the first 3 suppliers when creating a composite tuner and I think we've done that across every SDK consistently. I noticed that both Go and Java added the requirement for a Nexus slot supplier as a potentially breaking change, but maybe they got it in before tuning was GA? Or maybe they considered the breaking change acceptable?

I think we should try to do this part somewhat consistently across SDKs. Can you confirm 1) whether we want to require users provide explicit slot suppliers (at least for the first 3 types) when creating a composite tuner? and 2) whether we are ok with a backwards incompatible change to require Nexus slot supplier when creating a composite tuner? (note only some languages require the first 3 values for fixed, Go does not)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed offline and agreed to break create_composite while adding defaults to all for create_fixed. PR updated.

@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch from 769fd82 to 16bf494 Compare September 11, 2025 15:54
@dandavison dandavison changed the title Nexus support in worker tuner 💥 Nexus support in worker tuner Sep 11, 2025
@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch 2 times, most recently from a694631 to 34b6326 Compare September 12, 2025 14:43
@dandavison dandavison force-pushed the dan-9989-nexus-worker-tuner branch from 34b6326 to f6036bf Compare September 13, 2025 04:26
@dandavison dandavison merged commit 84b184f into main Sep 13, 2025
27 of 29 checks passed
@dandavison dandavison deleted the dan-9989-nexus-worker-tuner branch September 13, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants