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

Support PPE profiling for S3 #341

Merged
merged 4 commits into from
Aug 28, 2024
Merged

Support PPE profiling for S3 #341

merged 4 commits into from
Aug 28, 2024

Conversation

KantaTamura
Copy link
Contributor

This PR resolves the S3 task in #258

Sample program to check tracing

import json
import pytorch_pfn_extras as ppe

from pfio.v2 import S3, Path, from_url

def p():
    tracer = ppe.profiler.get_tracer()
    tracer.clear()

    fil = 0

    with from_url('pfs1://cluster-tutorial/', trace=True) as fs:
        assert isinstance(fs, S3)

        for f in fs.list(recursive=True):
            if f == "imagenet-classification.zip":
                continue

            with fs.open(f, 'rb') as fp:
                tmp = fp.read()

            fil += 1

            if fil > 10:
                break

    print(fil, "files")

    dict = tracer.state_dict()
    keys = [event["name"] for event in json.loads(dict["_event_list"])]
    print(keys)

    w = ppe.writing.SimpleWriter(out_dir="")
    tracer.initialize_writer("trace_s3.json", w)
    tracer.flush("trace_s3.json", w)

p()

output

11 files
['pfio.v2.S3:list-0', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-1', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-2', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-3', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-4', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-5', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-6', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-7', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-8', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-9', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-10', 'pfio.v2.S3:open', 'pfio.v2.S3:read', 'pfio.v2.S3:exit-context', 'pfio.v2.S3:list-11']

rendering of the output json file (trace.json) with chrome://tracing is shown below
image

@KantaTamura KantaTamura changed the title Support PPE profiling for `Local Support PPE profiling for S3 Aug 26, 2024
@KantaTamura
Copy link
Contributor Author

add profiling boto3 api
image

Copy link
Member

@k5342 k5342 left a comment

Choose a reason for hiding this comment

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

Overall, it looks good. I have one minor suggestion.

pfio/v2/s3.py Outdated
@@ -380,7 +423,8 @@ def _reset(self):

def _connect(self):
# print('boto3.client options:', kwargs)
self.client = boto3.client('s3', **self.kwargs)
obj = boto3.client('s3', **self.kwargs)
self.client = Boto3ProfileWrapper(obj)
Copy link
Member

Choose a reason for hiding this comment

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

It's better to switch here between the vanilla boto3 and the wrapped boto3 client by self.trace as well as Local fs does.

pfio/pfio/v2/local.py

Lines 123 to 127 in 9bf5900

# Add ppe recorder to io class methods (e.g. read, write)
if self.trace:
return LocalProfileIOWrapper(fp)
else:
return fp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot to change from test code ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix and rebase master branch

@k5342
Copy link
Member

k5342 commented Aug 28, 2024

PR #343 merge raised a conflict. Could you resolve the conflict before merging this, please?

@k5342 k5342 merged commit 43ea5de into pfnet:master Aug 28, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants