Skip to content

Commit 27712a0

Browse files
authored
Add a new experiment flag to enable real-time clock as processing time. (#35202)
1 parent 863823e commit 27712a0

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

sdks/go/pkg/beam/runners/prism/internal/engine/elementmanager.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ type Config struct {
161161
// MaxBundleSize caps the number of elements permitted in a bundle.
162162
// 0 or less means this is ignored.
163163
MaxBundleSize int
164+
// Whether to use real-time clock as processing time
165+
EnableRTC bool
164166
}
165167

166168
// ElementManager handles elements, watermarks, and related errata to determine
@@ -2158,11 +2160,12 @@ func (em *ElementManager) ProcessingTimeNow() (ret mtime.Time) {
21582160
if em.testStreamHandler != nil && !em.testStreamHandler.completed {
21592161
return em.testStreamHandler.Now()
21602162
}
2161-
// TODO toggle between testmode and production mode.
2163+
21622164
// "Test" mode -> advance to next processing time event if any, to allow execution.
2163-
// if test mode...
2164-
if t, ok := em.processTimeEvents.Peek(); ok {
2165-
return t
2165+
if !em.config.EnableRTC {
2166+
if t, ok := em.processTimeEvents.Peek(); ok {
2167+
return t
2168+
}
21662169
}
21672170

21682171
// "Production" mode, always real time now.

sdks/go/pkg/beam/runners/prism/internal/execute.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,18 @@ func executePipeline(ctx context.Context, wks map[string]*worker.W, j *jobservic
145145
topo := prepro.preProcessGraph(comps, j)
146146
ts := comps.GetTransforms()
147147

148-
em := engine.NewElementManager(engine.Config{})
148+
config := engine.Config{}
149+
m := j.PipelineOptions().AsMap()
150+
for _, exp := range m["beam:option:experiments:v1"].([]interface{}) {
151+
if expStr, ok := exp.(string); ok {
152+
if expStr == "prism_enable_rtc" {
153+
config.EnableRTC = true
154+
break // Found it, no need to check the rest of the slice
155+
}
156+
}
157+
}
158+
159+
em := engine.NewElementManager(config)
149160

150161
// TODO move this loop and code into the preprocessor instead.
151162
stages := map[string]*stage{}

0 commit comments

Comments
 (0)