From 5ce98bee74b19e336aac34dbc0129d6d4f45b7e0 Mon Sep 17 00:00:00 2001 From: Kevin Woo <3469532+kevinawoo@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:17:39 -0700 Subject: [PATCH 1/4] add missing import for Go's auto tuner --- docs/develop/worker-performance.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/develop/worker-performance.mdx b/docs/develop/worker-performance.mdx index 134650275f..b060efd7a3 100644 --- a/docs/develop/worker-performance.mdx +++ b/docs/develop/worker-performance.mdx @@ -274,6 +274,8 @@ These examples focus on Activities and Local Activities, since Workflow Tasks no ### Go SDK ```go +import "go.temporal.io/sdk/contrib/resourcetuner" + // Using the ResourceBasedTuner in worker options tuner, err := resourcetuner.NewResourceBasedTuner(resourcetuner.ResourceBasedTunerOptions{ TargetMem: 0.8, From 4be570a292221aa6261ff687ab1c3a68daa1e8dd Mon Sep 17 00:00:00 2001 From: Kevin Woo <3469532+kevinawoo@users.noreply.github.com> Date: Fri, 18 Apr 2025 12:05:00 -0700 Subject: [PATCH 2/4] use exported defaults --- docs/develop/worker-performance.mdx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/develop/worker-performance.mdx b/docs/develop/worker-performance.mdx index b060efd7a3..8036f89dcf 100644 --- a/docs/develop/worker-performance.mdx +++ b/docs/develop/worker-performance.mdx @@ -287,23 +287,24 @@ if err != nil { workerOptions := worker.Options{ Tuner: tuner } -// Combining different types -options := DefaultResourceControllerOptions() + +// Customize the tuner +options := resourcetuner.DefaultResourceControllerOptions() options.MemTargetPercent = 0.8 options.CpuTargetPercent = 0.9 -controller := NewResourceController(options) +controller := resourcetuner.NewResourceController(options) wfSS, err := worker.NewFixedSizeSlotSupplier(10) if err != nil { return err } -actSS := &ResourceBasedSlotSupplier{controller: controller, - options: defaultActivityResourceBasedSlotSupplierOptions()} -laSS := &ResourceBasedSlotSupplier{controller: controller, - options: defaultActivityResourceBasedSlotSupplierOptions()} + +actSS := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions()} +laSS := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions()} nexusSS, err := worker.NewFixedSizeSlotSupplier(10) if err != nil { return err } + compositeTuner, err := worker.NewCompositeTuner(worker.CompositeTunerOptions{ WorkflowSlotSupplier: wfSS, ActivitySlotSupplier: actSS, From b92d40663a51401d528d438db8f00a3640873951 Mon Sep 17 00:00:00 2001 From: Kevin Woo <3469532+kevinawoo@users.noreply.github.com> Date: Mon, 21 Apr 2025 12:53:15 -0700 Subject: [PATCH 3/4] fix syntax typos --- docs/develop/worker-performance.mdx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/develop/worker-performance.mdx b/docs/develop/worker-performance.mdx index 8036f89dcf..e01e8ba034 100644 --- a/docs/develop/worker-performance.mdx +++ b/docs/develop/worker-performance.mdx @@ -285,7 +285,7 @@ if err != nil { return err } workerOptions := worker.Options{ - Tuner: tuner + Tuner: tuner, } // Customize the tuner @@ -298,24 +298,24 @@ if err != nil { return err } -actSS := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions()} -laSS := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions()} +actSS, err := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions()) +laSS, err := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions()) nexusSS, err := worker.NewFixedSizeSlotSupplier(10) if err != nil { return err } compositeTuner, err := worker.NewCompositeTuner(worker.CompositeTunerOptions{ - WorkflowSlotSupplier: wfSS, - ActivitySlotSupplier: actSS, - LocalActivitySlotSupplier: laSS, - NexusSlotSupplier: nexusSS, + WorkflowSlotSupplier: wfSS, + ActivitySlotSupplier: actSS, + LocalActivitySlotSupplier: laSS, + NexusSlotSupplier: nexusSS, }) if err != nil { return err } workerOptions := worker.Options{ - Tuner: compositeTuner + Tuner: compositeTuner, } ``` From 400ac7792ab8f8d10a4943f257a4438bb205e2a2 Mon Sep 17 00:00:00 2001 From: Kevin Woo <3469532+kevinawoo@users.noreply.github.com> Date: Thu, 29 Jan 2026 10:54:33 -0800 Subject: [PATCH 4/4] Fix table formatting in multi-cluster replication docs --- .../multi-cluster-replication.mdx | 153 +++++++++--------- 1 file changed, 73 insertions(+), 80 deletions(-) diff --git a/docs/encyclopedia/temporal-service/multi-cluster-replication.mdx b/docs/encyclopedia/temporal-service/multi-cluster-replication.mdx index 97d2ef0a6a..efb47c7747 100644 --- a/docs/encyclopedia/temporal-service/multi-cluster-replication.mdx +++ b/docs/encyclopedia/temporal-service/multi-cluster-replication.mdx @@ -132,7 +132,7 @@ T = 0: adding event with event ID == 1 & version == 1 View in both Cluster A & B ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -146,7 +146,7 @@ T = 1: adding event with event ID == 2 & version == 1 View in both Cluster A & B ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -161,7 +161,7 @@ T = 2: adding event with event ID == 3 & version == 1 View in both Cluster A & B ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -178,7 +178,7 @@ adding event with event ID == 4 & version == 2 View in both Cluster A & B ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -195,7 +195,7 @@ T = 4: adding event with event ID == 5 & version == 2 View in both Cluster A & B ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -229,7 +229,7 @@ T = 0: View in both Cluster B & C ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -243,7 +243,7 @@ View in both Cluster B & C T = 1: adding event with event ID == 4 & version == 2 in Cluster B ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -258,7 +258,7 @@ T = 1: adding event with event ID == 4 & version == 2 in Cluster B T = 1: namespace failover to Cluster C, adding event with event ID == 4 & version == 3 in Cluster C ``` -| -------- | ------------- | --------------- | ------- | +| -------- | --------------- | --------------- | ------- | | Events | Version History | | -------- | --------------- | --------------- | ------- | | Event ID | Event Version | Event ID | Version | @@ -275,40 +275,38 @@ T = 2: replication task from Cluster C arrives in Cluster B Note: below are a tree structures ``` - | -------- | ------------- | - | Events | - | ------------- | ------------- | - | Event ID | Event Version | - | -------- | ------------- | - | 1 | 1 | - | 2 | 1 | - | 3 | 2 | - | -------- | ------------- | - | | - | ------------- | ------------ | - | | - | -------- | ------------- | | -------- | ------------- | - | Event ID | Event Version | | Event ID | Event Version | - | -------- | ------------- | | -------- | ------------- | - | 4 | 2 | | 4 | 3 | - | -------- | ------------- | | -------- | ------------- | - - | --------------- | ------- | - | Version History | - | --------------- | ------------------- | - | Event ID | Version | - | --------------- | ------- | - | 2 | 1 | - | 3 | 2 | - | --------------- | ------- | - | | - | ------- | ------------------- | - | | - | --------------- | ------- | | --------------- | ------- | - | Event ID | Version | | Event ID | Version | - | --------------- | ------- | | --------------- | ------- | - | 4 | 2 | | 4 | 3 | - | --------------- | ------- | | --------------- | ------- | +| ------------- | ------------- | +| Events | +| ------------- | ------------- | +| Event ID | Event Version | +| ------------- | ------------- | +| 1 | 1 | +| 2 | 1 | +| 3 | 2 | +| -------- | ------------- | +| | +| | +| -------- | ------------- | | -------- | ------------- | +| Event ID | Event Version | | Event ID | Event Version | +| -------- | ------------- | | -------- | ------------- | +| 4 | 2 | | 4 | 3 | +| -------- | ------------- | | -------- | ------------- | + +| --------------- | ------------------- | +| Version History | +| --------------- | ------------------- | +| Event ID | Version | +| --------------- | ------- | +| 2 | 1 | +| 3 | 2 | +| --------------- | ------------------- | +| | +| | +| --------------- | ------- | | --------------- | ------- | +| Event ID | Version | | Event ID | Version | +| --------------- | ------- | | --------------- | ------- | +| 4 | 2 | | 4 | 3 | +| --------------- | ------- | | --------------- | ------- | ``` T = 2: replication task from Cluster B arrives in Cluster C, same as above @@ -345,27 +343,22 @@ Multi-cluster Replication aims to keep the Workflow Execution History as up-to-d Due to the nature of Multi-cluster Replication (for example, Workflow Execution History events are replicated asynchronously) different Runs (same Namespace and Workflow Id) can arrive at the target Cluster at different times, sometimes out of order, as shown below: ``` -| ------------- | | ------------- | | ------------- | -| Cluster A | | Network Layer | | Cluster B | -| --------- || ------------- | | ------------- | - | | | - | Run 1 Replication Events | | - | -----------------------> | | - | | | - | Run 2 Replication Events | | - | -----------------------> | | - | | | - | | | - | | | - | | Run 2 Replication Events | - | | -----------------------> | - | | | - | | Run 1 Replication Events | - | | -----------------------> | - | | | - | --- || ------------- | | ------------- | -| Cluster A | | Network Layer | | Cluster B | -| --------- || ------------- | | ------------- | ++-----------+ +----------------+ +-----------+ +| Cluster A | | Network Layer | | Cluster B | ++-----------+ +----------------+ +-----------+ + | | | + | Run 1 Replication | | + |---------------------> | | + | | | + | Run 2 Replication | | + |---------------------> | | + | | | + | | Run 2 Replication | + | |---------------------> | + | | | + | | Run 1 Replication | + | |---------------------> | + | | | ``` Because Run 2 appears in Cluster B first, Run 1 cannot be replicated as "runnable" due to the rule `at most one Run open` (see above), thus the "zombie" Workflow Execution state is introduced. @@ -407,23 +400,23 @@ T = 0: task A is generated according to Event Id: 4, version: 2 T = 1: conflict resolution happens, Workflow Execution's mutable state is rebuilt and history Event Id: 4, version: 3 is written down to persistence ``` -| -------- | ------------- | -| Events | -| ------------- | -------------------------------------------- | -| Event ID | Event Version | -| -------- | ------------- | -| 1 | 1 | -| 2 | 1 | -| 3 | 2 | -| -------- | ------------- | -| | -| ------------- | -------------------------------------------- | -| | -| -------- | ------------- | | -------- | ------------- | -| Event ID | Event Version | | Event ID | Event Version | -| -------- | ------------- | | -------- | ------------- | -| 4 | 2 | <-- task A belongs to this event | 4 | 3 | <-- current branch / mutable state | -| -------- | ------------- | | -------- | ------------- | +| --------- | ------------- | +| Events | +| --------- | ------------- | +| Event ID | Event Version | +| -------- | ------------- | +| 1 | 1 | +| 2 | 1 | +| 3 | 2 | +| -------- | ------------- | +| | +| --------- | ------------- | +| | +| -------- | ------------- | | -------- | ------------- | +| Event ID | Event Version | | Event ID | Event Version | +| -------- | ------------- | | -------- | ------------- | +| 4 | 2 | <-- task A belongs to this event | 4 | 3 | <-- current branch / mutable state +| -------- | ------------- | | -------- | ------------- | ``` T = 2: task A is loaded.