prodriguezdefino commented on code in PR #41075:
URL: https://github.com/apache/beam/pull/41075#discussion_r4605925562


##########
sdks/go/pkg/beam/runners/prism/internal/engine/elementmanager.go:
##########
@@ -754,6 +754,9 @@ func (em *ElementManager) StateForBundle(rb RunBundle) 
TentativeData {
                ret.state = map[LinkID]map[typex.Window]map[string]StateData{}
        }
        for link, winMap := range ss.state {
+               if link == (LinkID{}) {
+                       continue
+               }

Review Comment:
   `ss.state` stores two kinds of data under different keys:
    - Non empty`LinkID` keys hold user `DoFn` state (`Bag` and `Multimap`).
    - The empty `LinkID{}` holds internal aggregation state (`Pane`, `Trigger`, 
and as this PR proposes `Accumulated`).
   
   `StateForBundle` copies only `Bag` and `Multimap` to pass user state to an 
SDK bundle. Copying `LinkID{}` creates empty `StateData` entries and wastes map 
allocations on every aggregation bundle.
   Also, `PersistBundle` overwrites `stage.state[link][w][key]` with entries 
from `TentativeData.state`. If a `LinkID{}` entry from `StateForBundle` ever 
reaches `PersistBundle`, it erases `Pane`, `Trigger`, and `Accumulated`. 
   
   Skipping `LinkID{}` prevents both the wasted work and that state loss.



-- 
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]

Reply via email to