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 FileCache / MultiprocessFileCache #345

Closed
wants to merge 5 commits into from

Conversation

KantaTamura
Copy link
Collaborator

This PR resolves the FileCache / MultiprocessFileCache task in #258

Note

preload() and preserve() are excluded from profiling because they are pre-processing and post-processing and have nothing to do with the I/O being executed.

Sample program to check tracing

import json
import pytorch_pfn_extras as ppe

from pfio.cache import FileCache, MultiprocessFileCache


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

    cache = FileCache(1, dir="./tmp", do_pickle=True, trace=True)
    cache.put(0, b"foo")
    assert b"foo" == cache.get(0)

    dict = ppe.profiler.get_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_filecache.json", w)
    tracer.flush("trace_filecache.json", w)


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

    cache = MultiprocessFileCache(1, dir="./tmp", do_pickle=True, trace=True)
    cache.put(0, b"foo")
    assert b"foo" == cache.get(0)

    dict = ppe.profiler.get_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_multiprocess_filecache.json", w)
    tracer.flush("trace_multiprocess_filecache.json", w)


filecache()
multiprocess_filecache()

output

['pfio.cache.file:put:lock', 'pfio.cache.file:put', 'pfio.cache.file:get:lock', 'pfio.cache.file:get']
['pfio.cache.multiprocessfile:put:lock-99', 'pfio.cache.multiprocessfile:put', 'pfio.cache.multiprocessfile:get:lock-99', 'pfio.cache.multiprocessfile:get']

rendering of the output json file with chrome://tracing is shown below

  • trace_filecache.json
    image

  • trace_multiprocess_filecache.json
    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.

We would like to persist records as get/put and lock separately to see the time-consuming task. Could you divide them?

change the record range while acquiring lock

Signed-off-by: KantaTamura <[email protected]>
@KantaTamura KantaTamura closed this Oct 9, 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