[ 
https://issues.apache.org/jira/browse/BEAM-9436?focusedWorklogId=410216&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-410216
 ]

ASF GitHub Bot logged work on BEAM-9436:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Mar/20 11:31
            Start Date: 26/Mar/20 11:31
    Worklog Time Spent: 10m 
      Work Description: echauchot commented on pull request #11055: [BEAM-9436] 
Improve GBK in spark structured streaming runner
URL: https://github.com/apache/beam/pull/11055#discussion_r398501823
 
 

 ##########
 File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/batch/functions/GroupAlsoByWindowViaOutputBufferFn.java
 ##########
 @@ -65,9 +65,15 @@ public GroupAlsoByWindowViaOutputBufferFn(
 
   @Override
   public Iterator<WindowedValue<KV<K, Iterable<InputT>>>> call(
-      KV<K, Iterable<WindowedValue<InputT>>> kv) throws Exception {
-    K key = kv.getKey();
-    Iterable<WindowedValue<InputT>> values = kv.getValue();
+      K key, Iterator<WindowedValue<KV<K, InputT>>> iterator) throws Exception 
{
+
+    // we have to meterialize the Iterator because 
ReduceFnRunner.processElements expects
+    // ArrayList<WindowedValue<InputT>> and not Iterator<WindowedValue<KV<K, 
InputT>>>
+    ArrayList<WindowedValue<InputT>> values = new ArrayList<>();
+    while (iterator.hasNext()) {
+      WindowedValue<KV<K, InputT>> wv = iterator.next();
+      values.add(wv.withValue(wv.getValue().getValue()));
 
 Review comment:
   I just ran this test: `-Xms8g -Xmx8g -Prunner=":runners:spark" 
-PloadTest.mainClass="org.apache.beam.sdk.loadtests.GroupByKeyLoadTest" 
-PloadTest.args="--fanout=1 --iterations=1 --streaming=false 
--runner=SparkStructuredStreamingRunner 
--sourceOptions={\"numRecords\":200000,\"keySizeBytes\":100000,\"valueSizeBytes\":10000,
 \"hotKeyFraction\":1.0, \"numHotKeys\":1}"` So one sole key that receives all 
the values in a 8GO JVM to simulate an OOM.
   And I observe a spill to disk and no out of memory as I said:
   before run /dev/mapper/ubuntu--vg-root   368G     23G  327G   7% /
   after run  /dev/mapper/ubuntu--vg-root   368G     27G  323G   8% /
   So +4G on disk in /tmp
   runtime_sec                   680.092
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 410216)
    Time Spent: 12h 40m  (was: 12.5h)

> Try to avoid elements list materialization in GBK
> -------------------------------------------------
>
>                 Key: BEAM-9436
>                 URL: https://issues.apache.org/jira/browse/BEAM-9436
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-spark
>            Reporter: Etienne Chauchot
>            Assignee: Etienne Chauchot
>            Priority: Major
>              Labels: structured-streaming
>          Time Spent: 12h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to