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

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

                Author: ASF GitHub Bot
            Created on: 19/Feb/20 13:23
            Start Date: 19/Feb/20 13:23
    Worklog Time Spent: 10m 
      Work Description: kamilwu commented on pull request #10885: [BEAM-9085] 
Fix performance regression in SyntheticSource
URL: https://github.com/apache/beam/pull/10885#discussion_r381285675
 
 

 ##########
 File path: sdks/python/apache_beam/testing/synthetic_pipeline.py
 ##########
 @@ -415,19 +418,24 @@ def get_range_tracker(self, start_position, 
stop_position):
       tracker = range_trackers.UnsplittableRangeTracker(tracker)
     return tracker
 
+  @staticmethod
+  def random_bytes(length):
+    """Return random bytes."""
+    return b''.join(
+        (struct.pack('B', random.getrandbits(8)) for _ in xrange(length)))
+
   def _gen_kv_pair(self, index):
-    r = np.random.RandomState(index)
-    rand = r.random_sample()
+    random.seed(index)
 
 Review comment:
   I'm pretty sure it's possible while having multiple range trackers and 
multiple workers.
   I wrote a fix and ran the benchmark. The performance is a bit worse:
   ```
   Python 2: 7.77728295326 (was 6.37386107445)
   Python 3: 6.888783617999998 (was 5.6981477510000005)
   ```
   However, we could create a cache for generators (instances of 
`random.Random`). Then we could create a generator for each range tracker, not 
for each index. This reduces the offset of instantiating multiple generators:
   ```
   Python 2: 6.42752218246
   Python 3: 5.789953311999998
   ```
   WDYT?
   
 
----------------------------------------------------------------
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: 389440)
    Time Spent: 50m  (was: 40m)

> Performance regression in np.random.RandomState() skews performance test 
> results across Python 2/3 on Dataflow
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: BEAM-9085
>                 URL: https://issues.apache.org/jira/browse/BEAM-9085
>             Project: Beam
>          Issue Type: Bug
>          Components: testing
>            Reporter: Kamil Wasilewski
>            Assignee: Kamil Wasilewski
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> Tests show that the performance of core Beam operations in Python 3.x on 
> Dataflow can be a few time slower than in Python 2.7. We should investigate 
> what's the cause of the problem.
> Currently, we have one ParDo test that is run both in Py3 and Py2 [1]. A 
> dashboard with runtime results can be found here [2].
> [1] sdks/python/apache_beam/testing/load_tests/pardo_test.py
> [2] https://apache-beam-testing.appspot.com/explore?dashboard=5678187241537536



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

Reply via email to