Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split env library so that there is only one instance of Env::Default() #43594

Merged
merged 3 commits into from Oct 9, 2020

Conversation

yongtang
Copy link
Member

While working on modular file systems, noticed that tensorflow's pip package
includes two copies of Env::Default() in two shared objects libraries.
One is in libtensorflow_framework.so, another is in _pywrap_tensorflow_internal.so.

Because of that, Env::Default() could return different instance depending on when
a modular file system is called. The Lookup vs. Register discrepancy may confuse the file
system to believe the scheme (e.g., s3/gcs) is not registered (actually registered
by another Env::Default()).

The duplication of Env::Default() is caused by the fact that tensorflow/core/platform:env
dependency is included in both libtensorflow_framework.so and _pywrap_tensorflow_internal.so.
in bazel indirectly.

There are two many dpendency graph component in between tensorflow/core/platform:env
and libtensorflow_framework.so/_pywrap_tensorflow_internal.so in bazel.
As a result this PR tries to address the issue by split out the Env::Default() implementation
out and only link it with libtensorflow_framework.so to guarantee libtensorflow_framework.so
is the only place to include Env::Default().

Signed-off-by: Yong Tang yong.tang.github@outlook.com

@google-ml-butler google-ml-butler bot added the size:S CL Change Size: Small label Sep 27, 2020
@gbaned gbaned self-assigned this Sep 27, 2020
@gbaned gbaned added the comp:core issues related to core part of tensorflow label Sep 27, 2020
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Sep 27, 2020
@gunan gunan removed their request for review September 28, 2020 16:25
mihaimaruseac
mihaimaruseac previously approved these changes Sep 28, 2020
Copy link
Collaborator

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find. Thank you

PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Sep 28, 2020
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Sep 28, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Sep 28, 2020
@gbaned gbaned added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Sep 29, 2020
@mihaimaruseac
Copy link
Collaborator

This one needs a lot of changes internally since we also have a Google-only Env with separate implementations. I'll be working on importing this manually, but will probably take a little bit longer.

@mihaimaruseac
Copy link
Collaborator

There is actually an issue with splitting things out like here. External packages using TF Bazel (not from pip package) are supposed to be able to get to Env:Default by just depending on //tensorflow/core:lib but with this change they would fail.

While working on modular file systems, noticed that tensorflow's pip package
includes two copies of `Env::Default()` in two shared objects libraries.
One is in `libtensorflow_framework.so`, another is in `_pywrap_tensorflow_internal.so`.

Because of that, `Env::Default()` could return different instance depending on when
a modular file system is called. The Lookup vs. Register discrepancy may confuse the file
system to believe the scheme (e.g., `s3`/`gcs`) is not registered (actually registered
by another `Env::Default()`).

The duplication of `Env::Default()` is caused by the fact that `tensorflow/core/platform:env`
dependency is included in both `libtensorflow_framework.so` and `_pywrap_tensorflow_internal.so`.
in bazel indirectly.

There are two many dpendency graph component in between `tensorflow/core/platform:env`
and `libtensorflow_framework.so`/`_pywrap_tensorflow_internal.so` in bazel.
As a result this PR tries to address the issue by split out the `Env::Default()` implementation
out and only link it with `libtensorflow_framework.so` to guarantee `libtensorflow_framework.so`
is the only place to include `Env::Default()`.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
…rnal_impl

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
So that  //tensorflow/core:lib includes `Env:Default`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
PR Queue automation moved this from Approved by Reviewer to Reviewer Requested Changes Oct 6, 2020
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Oct 6, 2020
@yongtang
Copy link
Member Author

yongtang commented Oct 6, 2020

Thanks @mihaimaruseac for the help. I have made additional changes to the PR and //tensorflow/core:lib should include Env:Default. Can you give it a try?

@yongtang yongtang added the kokoro:force-run Tests on submitted change label Oct 6, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Oct 6, 2020
PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Oct 7, 2020
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Oct 7, 2020
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Oct 7, 2020
@gbaned gbaned added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Oct 9, 2020
@copybara-service copybara-service bot merged commit b62b9cf into tensorflow:master Oct 9, 2020
PR Queue automation moved this from Approved by Reviewer to Merged Oct 9, 2020
@yongtang yongtang deleted the env_impl branch October 9, 2020 18:47
copybara-service bot pushed a commit that referenced this pull request Oct 9, 2020
PiperOrigin-RevId: 336361140
Change-Id: I9c331eb08b71502c00235a9bad959372c82b46c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:core issues related to core part of tensorflow ready to pull PR ready for merge process size:S CL Change Size: Small
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

5 participants