dynamic_worker_pool_scheduler.go ×10

Frontier kind: Code frontier

unlabeled · c_b279fb42c434

2 tests · 1642 LOC · 65 files · introduces 0 tests · 60 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges60 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
201 ranges1642 lines · 65 files · Browse complete extent
All tests (intent)
2 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationoutbound_queue_factory.go ×8 · 144 introduced LOCoutbound_queue_factory.g…task_mock.go ×6 · 53 introduced LOCtask_mock.go ×6priority.go ×1 · 3 introduced LOCpriority.go ×1setting_gen.go ×51 · 335 introduced LOCsetting_gen.go ×51noop_impl.go ×1 · 3 introduced LOCnoop_impl.go ×1noop_impl.go ×1 · 1 introduced LOCnoop_impl.go ×1service.pb.go ×2 · 342 introduced LOCservice.pb.go ×2message.pb.go ×2 · 20 introduced LOCmessage.pb.go ×2message.pb.go ×2 · 442 introduced LOCmessage.pb.go ×2defs.go ×1 · 3 introduced LOCdefs.go ×1metrics.go ×1 · 1 introduced LOCmetrics.go ×1defs.go ×5 · 91 introduced LOCdefs.go ×5tags.go ×9 · 37 introduced LOCtags.go ×9message.pb.go ×2 · 49 introduced LOCmessage.pb.go ×2cluster.pb.go ×2 · 200 introduced LOCcluster.pb.go ×2wildcard.go ×1 · 2 introduced LOCwildcard.go ×1wildcard.go ×4 · 14 introduced LOCwildcard.go ×4retrypolicy.go ×3 · 19 introduced LOCretrypolicy.go ×3message.pb.go ×2 · 20 introduced LOCmessage.pb.go ×2TestOperatorServiceMetadata, TestWorkflowServiceMetadata · 0 introduced LOCTestOperatorServiceMetad…go.temporal.io/server/api/adminservice/v1/request_response.pb.go · 6661 LOCv1/request_response.pb.g…go.temporal.io/server/api/adminservice/v1/service.pb.go · 297 LOCv1/service.pb.gogo.temporal.io/server/api/clock/v1/message.pb.go · 217 LOCv1/message.pb.gogo.temporal.io/server/api/cluster/v1/message.pb.go · 366 LOCv1/message.pb.gogo.temporal.io/server/api/common/v1/api_category.pb.go · 230 LOCv1/api_category.pb.gogo.temporal.io/server/api/common/v1/dlq.pb.go · 319 LOCv1/dlq.pb.gogo.temporal.io/server/api/deployment/v1/message.pb.go · 4650 LOCv1/message.pb.gogo.temporal.io/server/api/enums/v1/cluster.pb.go · 233 LOCv1/cluster.pb.gogo.temporal.io/server/api/enums/v1/common.pb.go · 288 LOCv1/common.pb.gogo.temporal.io/server/api/enums/v1/dlq.pb.go · 211 LOCv1/dlq.pb.gogo.temporal.io/server/api/enums/v1/fairness_state.pb.go · 147 LOCv1/fairness_state.pb.gogo.temporal.io/server/api/enums/v1/nexus.pb.go · 182 LOCv1/nexus.pb.gogo.temporal.io/server/api/enums/v1/predicate.pb.go · 194 LOCv1/predicate.pb.gogo.temporal.io/server/api/enums/v1/replication.pb.go · 338 LOCv1/replication.pb.gogo.temporal.io/server/api/enums/v1/task.pb.go · 480 LOCv1/task.pb.gogo.temporal.io/server/api/enums/v1/workflow.pb.go · 299 LOCv1/workflow.pb.gogo.temporal.io/server/api/enums/v1/workflow_task_type.pb.go · 148 LOCv1/workflow_task_type.pb…go.temporal.io/server/api/errordetails/v1/message.pb.go · 649 LOCv1/message.pb.gogo.temporal.io/server/api/health/v1/message.pb.go · 324 LOCv1/message.pb.gogo.temporal.io/server/api/history/v1/message.pb.go · 522 LOCv1/message.pb.gogo.temporal.io/server/api/historyservice/v1/request_response.pb.go · 12003 LOCv1/request_response.pb.g…go.temporal.io/server/api/historyservice/v1/service.pb.go · 452 LOCv1/service.pb.gogo.temporal.io/server/api/matchingservice/v1/request_response.pb.go · 6878 LOCv1/request_response.pb.g…go.temporal.io/server/api/matchingservice/v1/service.pb.go · 274 LOCv1/service.pb.gogo.temporal.io/server/api/metrics/v1/message.pb.go · 128 LOCv1/message.pb.gogo.temporal.io/server/api/namespace/v1/message.pb.go · 138 LOCv1/message.pb.gogo.temporal.io/server/api/persistence/v1/chasm.pb.go · 1215 LOCv1/chasm.pb.gogo.temporal.io/server/api/persistence/v1/chasm_visibility.pb.go · 170 LOCv1/chasm_visibility.pb.g…go.temporal.io/server/api/persistence/v1/cluster_metadata.pb.go · 313 LOCv1/cluster_metadata.pb.g…go.temporal.io/server/api/persistence/v1/executions.pb.go · 5768 LOCv1/executions.pb.gogo.temporal.io/server/api/persistence/v1/history_tree.pb.go · 298 LOCv1/history_tree.pb.gogo.temporal.io/server/api/persistence/v1/hsm.pb.go · 929 LOCv1/hsm.pb.gogo.temporal.io/server/api/persistence/v1/namespaces.pb.go · 560 LOCv1/namespaces.pb.gogo.temporal.io/server/api/persistence/v1/nexus.pb.go · 509 LOCv1/nexus.pb.gogo.temporal.io/server/api/persistence/v1/predicates.pb.go · 864 LOCv1/predicates.pb.gogo.temporal.io/server/api/persistence/v1/queue_metadata.pb.go · 129 LOCv1/queue_metadata.pb.gogo.temporal.io/server/api/persistence/v1/queues.pb.go · 641 LOCv1/queues.pb.gogo.temporal.io/server/api/persistence/v1/task_queues.pb.go · 924 LOCv1/task_queues.pb.gogo.temporal.io/server/api/persistence/v1/tasks.pb.go · 870 LOCv1/tasks.pb.gogo.temporal.io/server/api/persistence/v1/update.pb.go · 455 LOCv1/update.pb.gogo.temporal.io/server/api/persistence/v1/workflow_mutable_state.pb.go · 560 LOCv1/workflow_mutable_stat…go.temporal.io/server/api/replication/v1/message.pb.go · 2481 LOCv1/message.pb.gogo.temporal.io/server/api/taskqueue/v1/message.pb.go · 1363 LOCv1/message.pb.gogo.temporal.io/server/api/token/v1/message.pb.go · 809 LOCv1/message.pb.gogo.temporal.io/server/api/workflow/v1/message.pb.go · 302 LOCv1/message.pb.gogo.temporal.io/server/common/backoff/retrypolicy.go · 347 LOCbackoff/retrypolicy.gogo.temporal.io/server/common/build/build.go · 56 LOCbuild/build.gogo.temporal.io/server/common/dynamicconfig/collection.go · 779 LOCdynamicconfig/collection…go.temporal.io/server/common/dynamicconfig/deepcopy.go · 78 LOCdynamicconfig/deepcopy.g…go.temporal.io/server/common/dynamicconfig/gradual_change.go · 196 LOCdynamicconfig/gradual_ch…go.temporal.io/server/common/dynamicconfig/key.go · 21 LOCdynamicconfig/key.gogo.temporal.io/server/common/dynamicconfig/registry.go · 44 LOCdynamicconfig/registry.g…go.temporal.io/server/common/dynamicconfig/setting_gen.go · 1972 LOCdynamicconfig/setting_ge…go.temporal.io/server/common/dynamicconfig/shared_structure.go · 69 LOCdynamicconfig/shared_str…go.temporal.io/server/common/log/tag/tags.go · 1039 LOCtag/tags.gogo.temporal.io/server/common/log/tag/zap_tag.go · 242 LOCtag/zap_tag.gogo.temporal.io/server/common/metrics/defs.go · 76 LOCmetrics/defs.gogo.temporal.io/server/common/metrics/defs_base.go · 30 LOCmetrics/defs_base.gogo.temporal.io/server/common/metrics/metrics.go · 85 LOCmetrics/metrics.gogo.temporal.io/server/common/metrics/noop_impl.go · 58 LOCmetrics/noop_impl.gogo.temporal.io/server/common/metrics/option.go · 21 LOCmetrics/option.gogo.temporal.io/server/common/metrics/registry.go · 75 LOCmetrics/registry.gogo.temporal.io/server/common/tasks/dynamic_worker_pool_scheduler.go · 175 LOCtasks/dynamic_worker_poo…go.temporal.io/server/common/tasks/priority.go · 81 LOCtasks/priority.gogo.temporal.io/server/common/tasks/runnable_scheduler.go · 72 LOCtasks/runnable_scheduler…go.temporal.io/server/common/tasks/task_mock.go · 220 LOCtasks/task_mock.gogo.temporal.io/server/common/util/wildcard.go · 50 LOCutil/wildcard.gogo.temporal.io/server/service/history/circuitbreakerpool/circuit_breaker_factory.go · 22 LOCcircuitbreakerpool/circu…go.temporal.io/server/service/history/outbound_queue_factory.go · 379 LOChistory/outbound_queue_f…go.temporal.io/server/service/history/queues/executable.go · 979 LOCqueues/executable.gogo.temporal.io/server/service/history/queues/metrics.go · 246 LOCqueues/metrics.gogo.temporal.io/server/service/history/queues/scheduler_quotas.go · 87 LOCqueues/scheduler_quotas.…go.temporal.io/server/service/history/tasks/chasm_task.go · 130 LOCtasks/chasm_task.goTestOperatorServiceMetadata · introduced test · go.temporal.io/server/common/api/TestOperatorServiceMetadataTestOperatorServiceMetad…TestWorkflowServiceMetadata · introduced test · go.temporal.io/server/common/api/TestWorkflowServiceMetadataTestWorkflowServiceMetad…TestTSCBWithDynamicSettings · introduced test · go.temporal.io/server/common/circuitbreaker/TestTSCBWithDynamicSettingsTestTSCBWithDynamicSetti…TestDeepCopy_OtherReferenceTypes_Nil · introduced test · go.temporal.io/server/common/dynamicconfig/TestDeepCopy_OtherReferenceTypes_NilTestDeepCopy_OtherRefere…TestMutexMapBaggage · introduced test · go.temporal.io/server/common/metrics/TestBaggageBenchSuite/TestMutexMapBaggageTestMutexMapBaggageTestSyncMapBaggage · introduced test · go.temporal.io/server/common/metrics/TestBaggageBenchSuite/TestSyncMapBaggageTestSyncMapBaggageTestDynamicWorkerPoolSchedulerLogic · introduced test · go.temporal.io/server/common/tasks/TestDynamicWorkerPoolSchedulerLogicTestDynamicWorkerPoolSch…TestOutboundQueueFactory_ChasmTaskGroupWiring · introduced test · go.temporal.io/server/service/history/TestOutboundQueueFactory_ChasmTaskGroupWiringTestOutboundQueueFactory…TestAPIPrioritiesOrdered · introduced test · go.temporal.io/server/service/matching/configs/TestQuotasSuite/TestAPIPrioritiesOrderedTestAPIPrioritiesOrderedTestAPIToPriorityMapping · introduced test · go.temporal.io/server/service/matching/configs/TestQuotasSuite/TestAPIToPriorityMappingTestAPIToPriorityMappingFocused concept · dynamic_worker_pool_scheduler.go ×10 · 60 introduced LOCdynamic_worker_pool_sche…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 60 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/tasks/dynamic_worker_pool_scheduler.go 60 introduced LOC · 10 ranges

Open complete file

46 limiter DynamicWorkerPoolLimiter,
47 metricsHandler metrics.Handler,
48 > ) *DynamicWorkerPoolScheduler { dynamic_worker_pool_scheduler.go
49 > stopCtx, stopFn := context.WithCancel(context.Background())
50 > scheduler := &DynamicWorkerPoolScheduler{
51 > stopCtx: stopCtx,
52 > stopFn: stopFn,
53 > limiter: limiter,
54 > buffer: list.New(),
55 >
56 > metricsHandler: metricsHandler,
57 > }
58 > scheduler.wg.Add(1)
59 > go scheduler.exportMetricsWorker()
60 > return scheduler
61 > }
62
63 // InitiateShutdown aborts all buffered tasks and empties the buffer.
64 > func (pool *DynamicWorkerPoolScheduler) InitiateShutdown() { dynamic_worker_pool_scheduler.go
65 > pool.stopFn()
66 > pool.mu.Lock()
67 > // Prevent any running goroutines from picking up already aborted runnables.
68 > buffer := pool.buffer
69 > pool.buffer = list.New()
70 > pool.mu.Unlock()
71 > for elem := buffer.Front(); elem != nil; elem = elem.Next() {
72 elem.Value.(Runnable).Abort()
73 }
75
76 // WaitShutdown waits for all worker goroutines to complete.
77 > func (pool *DynamicWorkerPoolScheduler) WaitShutdown() { dynamic_worker_pool_scheduler.go
78 > pool.wg.Wait()
79 > }
80
81 > func (pool *DynamicWorkerPoolScheduler) TrySubmit(task Runnable) bool { dynamic_worker_pool_scheduler.go
82 > // First add to the waitgroup, then check stopCtx.Err to ensure InitiateShutdown() (which first cancels the stopCtx,
83 > // then waits for the waitgroup) always gets a chance to wait for submitted tasks, even when TrySubmit() and Stop()
84 > // are called concurrently.
85 > pool.wg.Add(1)
86 > if pool.stopCtx.Err() != nil {
87 // No need to reschedule this task, just abort after we've shut down.
88 pool.wg.Done()
90 return true
91 }
92 > pool.mu.Lock() dynamic_worker_pool_scheduler.go
93 > if pool.runningGoroutines >= pool.limiter.Concurrency() {
94 enqueued := pool.tryEnqueueLocked(task)
95 pool.mu.Unlock()
104 return enqueued
105 }
106 > pool.runningGoroutines++ dynamic_worker_pool_scheduler.go
107 > pool.mu.Unlock()
108 > go pool.executeUntilBufferEmpty(task)
109 > return true
110 }
111
112 // executeUntilBufferEmpty execute tasks starting from the given task using the provided limiter.
113 // Continues as long as it has tasks to dequeue.
114 > func (pool *DynamicWorkerPoolScheduler) executeUntilBufferEmpty(task Runnable) { dynamic_worker_pool_scheduler.go
115 > defer pool.wg.Done()
116 > for {
117 > task.Run(pool.stopCtx)
118 >
119 > pool.mu.Lock()
120 > nextTask, ok := pool.dequeueLocked()
121 > if !ok {
122 > pool.runningGoroutines--
123 > pool.mu.Unlock()
124 > break
125 }
126 task = nextTask
132
133 // dequeueLocked dequeues a task from the pool's buffer. Must be called while holding the lock.
134 > func (pool *DynamicWorkerPoolScheduler) dequeueLocked() (task Runnable, ok bool) { dynamic_worker_pool_scheduler.go
135 > if elem := pool.buffer.Front(); elem != nil {
136 task := elem.Value.(Runnable)
137 pool.buffer.Remove(elem)
154 }
155
156 > func (pool *DynamicWorkerPoolScheduler) exportMetricsWorker() { dynamic_worker_pool_scheduler.go
157 > defer pool.wg.Done()
158 > // TODO(rodrigozhou) add a dynamic config for the ticker interval
159 > timer := time.NewTicker(10 * time.Second)
160 > for {
161 > select {
162 > case <-pool.stopCtx.Done():
163 > timer.Stop()
164 > return
165 case <-timer.C:
166 pool.mu.Lock()