-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize job pickling to speed up Manager thread performance on larg…
…e graphs (#211) * remove creator from pickled Job objects
- Loading branch information
1 parent
311ebfd
commit 3181d72
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Author: Jan-Thorsten Peter <[email protected]> | ||
|
||
import copy | ||
import os | ||
import logging | ||
import gzip | ||
|
@@ -239,12 +240,29 @@ def __hash__(self): | |
# TODO Check how uninitialized object should behave here | ||
return hash((self.__dict__.get("creator"), self.__dict__.get("path"))) | ||
|
||
def __sis_state__(self): | ||
d = self.__dict__.copy() | ||
del d["users"] | ||
return d | ||
|
||
def __deepcopy__(self, memo): | ||
cls = self.__class__ | ||
result = cls.__new__(cls) | ||
memo[id(self)] = result | ||
for k, v in self.__dict__.items(): | ||
if k != "users": | ||
setattr(result, k, copy.deepcopy(v, memo)) | ||
result.users = set() | ||
return result | ||
|
||
def __getstate__(self): | ||
"""Skips exporting users | ||
:return: | ||
""" | ||
d = self.__dict__.copy() | ||
del d["users"] | ||
d = self.__sis_state__() | ||
if not gs.INCLUDE_CREATOR_STATE and hasattr(self, "creator"): | ||
d["path"] = self.get_path() | ||
d["creator"] = None | ||
return d | ||
|
||
def __setstate__(self, state): | ||
|
@@ -277,7 +295,7 @@ def __repr__(self): | |
def copy(self): | ||
"""Creates a copy of this Path""" | ||
new = Path("") | ||
new.__setstate__(self.__getstate__()) | ||
new.__setstate__(self.__sis_state__()) | ||
return new | ||
|
||
def copy_append(self, suffix): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters