schizophrenicmaniac opened a new pull request, #41603:
URL: https://github.com/apache/beam/pull/41603

   On Streaming Engine, MapState and MultimapState are both backed by 
WindmillMultimap, which always put itself into WindmillStateCache with a weight 
of 1. The cache never saw how much data the multimap was holding, so 
`--workerCacheMb` didn't bound it and workers could run out of heap.
   
   This tracks a weight per KeyState: the encoded key size once known, plus the 
encoded size of the cached values. It also keeps a running total on the 
multimap. Values added in persistDirectly use the sizes already computed while 
encoding them, and values read from Windmill use the weight WindmillStateReader 
already attaches. The total is reduced whenever a KeyState's values are dropped 
or the KeyState is removed from keyStateMap: remove(), clear(), and the pruning 
in persistDirectly, get(), keys() and entries(). The cache weight is now the 
state key size plus that total plus a rough fixed overhead for each cached key.
   
   I added two tests to WindmillStateInternalsTest that check the cache weight 
for a multimap (get/put, remove, clear) and for a MapState backed by a 
multimap, where overwriting a value replaces its weight instead of adding to it.
   
   WindmillMap has the same hardcoded 1, but I kept this PR to the multimap 
path that the issue hits. I can follow up on that separately if it's useful.
   
   Fixes #41597


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