Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2351#discussion_r18006482
  
    --- Diff: python/pyspark/context.py ---
    @@ -793,6 +796,40 @@ def runJob(self, rdd, partitionFunc, partitions=None, 
allowLocal=False):
             it = self._jvm.PythonRDD.runJob(self._jsc.sc(), mappedRDD._jrdd, 
javaPartitions, allowLocal)
             return list(mappedRDD._collect_iterator_through_file(it))
     
    +    def _add_profile(self, id, profileAcc):
    +        if not self._profile_stats:
    +            dump_path = self._conf.get("spark.python.profile.dump")
    +            if dump_path:
    +                atexit.register(self.dump_profiles, dump_path)
    +            else:
    +                atexit.register(self.show_profiles)
    +
    +        self._profile_stats.append([id, profileAcc, False])
    +
    +    def show_profiles(self):
    +        """ Print the profile stats to stdout """
    +        for i, (id, acc, showed) in self._profile_stats:
    +            stats = acc.value
    +            if not showed and stats:
    +                print "=" * 60
    +                print "Profile of RDD<id=%d>" % id
    +                print "=" * 60
    +                stats.sort_stats("tottime", "cumtime").print_stats()
    +                # mark it as showed
    +                self._profile_stats[i][2] = True
    +
    +    def dump_profiles(self, path):
    +        """ Dump the profile stats into directory `path`
    +        """
    +        if not os.path.exists(path):
    +            os.makedirs(path)
    +        for id, acc, _ in self._created_profiles:
    --- End diff --
    
    This should probably be `self._profile_stats`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to