Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support caching in Apache Beam by using relative co_filename paths. (#…
…32979) * The motivation for this change is to support caching in Apache Beam. Apache Beam does the following: - Pickle Python code - Send the pickled source code to "worker" VMs - The workers unpickle and execute the code In the environment that these Beam pipelines execute, the source code is in a temporary directory whose name is random and changes. The source code paths relative to the temporary directory are constant. Using absolute paths prevents pickled code from being cached because the absolute path keeps changing. Using relative paths enables this caching and promises significant resource savings and speed-ups. Additionally the absolute paths leak information about the directory structure of the machine pickling the source code. When the pickled code is passed across the network to another machine, the absolute paths may no longer be valid when the other machine has a different directory structure. The reason for using relative paths rather than omitting the path entirely is because Python uses the co_filename attribute to create stack traces. * The motivation for this change is to support caching in Apache Beam for Google. Apache Beam does the following: - Pickle Python code - Send the pickled source code to "worker" VMs - The workers unpickle and execute the code In the environment that these Beam pipelines execute, the source code is in a temporary directory whose name is random and changes. The source code paths relative to the temporary directory are constant. Using absolute paths prevents pickled code from being cached because the absolute path keeps changing. Using relative paths enables this caching and promises significant resource savings and speed-ups. Additionally the absolute paths leak information about the directory structure of the machine pickling the source code. When the pickled code is passed across the network to another machine, the absolute paths may no longer be valid when the other machine has a different directory structure. The reason for using relative paths rather than omitting the path entirely is because Python uses the co_filename attribute to create stack traces. * Simplify. --------- Co-authored-by: Robert Bradshaw <[email protected]>
- Loading branch information