[
https://issues.apache.org/jira/browse/BEAM-11097?focusedWorklogId=665221&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-665221
]
ASF GitHub Bot logged work on BEAM-11097:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Oct/21 18:56
Start Date: 13/Oct/21 18:56
Worklog Time Spent: 10m
Work Description: lostluck commented on a change in pull request #15717:
URL: https://github.com/apache/beam/pull/15717#discussion_r728225713
##########
File path: sdks/go/pkg/beam/core/runtime/harness/statecache/statecache.go
##########
@@ -44,18 +52,19 @@ type token string
type SideInputCache struct {
capacity int
mu sync.Mutex
- cache map[token]exec.ReStream
+ cache map[cacheKey]exec.ReStream
idsToTokens map[string]token
validTokens map[token]int8 // Maps tokens to active bundle counts
metrics CacheMetrics
}
// CacheMetrics stores metrics for the cache across a pipeline run.
type CacheMetrics struct {
- Hits int64
- Misses int64
- Evictions int64
- InUseEvictions int64
+ Hits *metrics.Counter
+ Misses *metrics.Counter
+ Evictions *metrics.Counter
+ InUseEvictions *metrics.Counter
+ ReStreamErrors *metrics.Counter
Review comment:
style nit: Go permits singlelining field declarations when the types are
the same, for scenarios exactly like this.
`Hits, Misses, Evictions, InUseEvictions, ReStreamErrors int64`
##########
File path: sdks/go/pkg/beam/core/runtime/harness/statecache/statecache.go
##########
@@ -145,19 +150,24 @@ func (c *SideInputCache)
makeAndValidateToken(transformID, sideInputID string) (
return tok, c.isValid(tok)
}
+func (c *SideInputCache) makeCacheKey(tok token, w, key []byte) cacheKey {
+ return cacheKey{tok: tok, win: string(w), key: string(key)}
+}
+
// QueryCache takes a transform ID and side input ID and checking if a
corresponding side
// input has been cached. A query having a bad token (e.g. one that doesn't
make a known
// token or one that makes a known but currently invalid token) is treated the
same as a
// cache miss.
-func (c *SideInputCache) QueryCache(transformID, sideInputID string)
exec.ReStream {
+func (c *SideInputCache) QueryCache(ctx context.Context, transformID,
sideInputID string, win, key []byte) exec.ReStream {
c.mu.Lock()
defer c.mu.Unlock()
tok, ok := c.makeAndValidateToken(transformID, sideInputID)
if !ok {
return nil
}
+ keyString := c.makeCacheKey(tok, win, key)
Review comment:
nit: No longer a string, and the scope is 3 lines, so just call it
`ck`. Ths is a Go Idiom, the shorter the distance a name needs to travel, the
shorter it can be. The shortness indicates that it's definition is likely not
far away or it's fairly standard (like using r and w for io.Reader and
io.Writer values).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 665221)
Time Spent: 12h 10m (was: 12h)
> [Go SDK] Windowed Side Input Caching (Cross Bundle)
> ---------------------------------------------------
>
> Key: BEAM-11097
> URL: https://issues.apache.org/jira/browse/BEAM-11097
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Reporter: Robert Burke
> Assignee: Jack McCluskey
> Priority: P3
> Labels: starter
> Time Spent: 12h 10m
> Remaining Estimate: 0h
>
> This is implementing https://issues.apache.org/jira/browse/BEAM-5428 for the
> Go SDK.
> Side inputs are valid for given window. That means they can be and correctly
> cached and re-used in multiple bundles if the data has already been loaded
> into a given worker.
> Side input data for a given bundle is specified and keyed by the window and a
> a side input request token. The Go SDK presently doesn't use this information
> for a SDK side worker cache of data.
> Care needs to be taken to allow the data to be garbage collected if it hasn't
> been used in the last minute or so. In practice, Global Window side inputs
> will not be evicted while still in use, but infrequently accessed data will
> possibly be evicted more regularly. A limit should be set to avoid running
> out of memory.
> As presently implemented, each ProcessElement call (or StartBundle or
> FinishBundle) will only query for side input data on user request. However,
> results of user requests are not cached between elements or bundles, which
> means there's additional lookup and serialization time from the runner side.
> It may be possible to re-use allocated side input elements, but even a
> solution that re-decodes data on every call would be an improvement if the
> data isn't re-streamed from the runner.
> If https://issues.apache.org/jira/browse/BEAM-3293 has been implemented, then
> per-key+window caching should additionally be considered for more granular
> caching of data.
> This optimization has an outsized impact on streaming performance as side
> input data can change per bundle, and streaming bundles are typically small,
> and quickly processed.
> This work would be implemented in the exec package:
>
> [https://github.com/apache/beam/blob/master/sdks/go/pkg/beam/core/runtime/exec/sideinput.go]
>
> and probably the harness package
>
> [https://github.com/apache/beam/blob/c185adb7652034b5d044aae65a1a972d9ceb4377/sdks/go/pkg/beam/core/runtime/harness/statemgr.go#L50]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)