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 Zip #344

Merged
merged 4 commits into from
Aug 28, 2024
Merged

Support PPE profiling for Zip #344

merged 4 commits into from
Aug 28, 2024

Conversation

KantaTamura
Copy link
Contributor

This PR resolves the Zip task in #258

Sample program to check tracing

import json
import pytorch_pfn_extras as ppe

from pfio.v2 import Local, Path, from_url
from pfio.testing import ZipForTest


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

    zipfilename = "test.zip"
    data = dict(
        foo = b'foo',
        bar = b'bar',
        foobar = b'foobar',
    )
    file = ZipForTest(zipfilename, data)

    with from_url(zipfilename, trace=True) as fs:
        for name in fs.list(recursive=True):
            with fs.open(name, mode='rb') as fp:
                tmp = fp.read()
                assert file.content(name) == tmp

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

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


p()

output

['pfio.v2.Local:open', 'pfio.v2.Local:seek', 'pfio.v2.Local:tell', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Zip:create-zipfile-obj', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Local:seekable', 'pfio.v2.Zip:open', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Zip:read', 'pfio.v2.Zip:exit-context', 'pfio.v2.Zip:list-0', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Local:seekable', 'pfio.v2.Zip:open', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Zip:read', 'pfio.v2.Zip:exit-context', 'pfio.v2.Zip:list-1', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Local:seekable', 'pfio.v2.Zip:open', 'pfio.v2.Local:seek', 'pfio.v2.Local:read', 'pfio.v2.Local:tell', 'pfio.v2.Zip:read', 'pfio.v2.Zip:exit-context', 'pfio.v2.Zip:list-2', 'pfio.v2.Local:close', 'pfio.v2.Zip:close']

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

@k5342
Copy link
Member

k5342 commented Aug 28, 2024

LGTM. Thanks!

@k5342 k5342 merged commit 14f0232 into pfnet:master Aug 28, 2024
7 checks passed
@kuenishi kuenishi added this to the 2.9.0 milestone Sep 3, 2024
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.

3 participants