GithubHelp home page GithubHelp logo

Comments (10)

gaogaotiantian avatar gaogaotiantian commented on May 29, 2024 1

Also I'll review the code when I got some time :)

from viztracer.

gaogaotiantian avatar gaogaotiantian commented on May 29, 2024

I'm curious about the actual usage for this. Is there a reason that you can't or won't use the command line tool? Do you need to switch between log_sparse mode and the normal mode frequently when you profile your program?

log_sparse mode is basically turning off the tracer, which makes the VizTracer context weird - it really doesn't do anything except for creating a new instance.

There's an actual concern here though - currently we promise @log_sparse decorator introduces no run-time overhead (of course when calling, not decorating) if there's no tracer. This is a very good feature as the users would be comfortable leaving the decorator as it is, even for production code. By introducing run-time check for the tracer, we break that promise, which may counteract the fact that we are slightly more flexible when using the feature.

from viztracer.

AlexeyKozhevin avatar AlexeyKozhevin commented on May 29, 2024

I would like to use your library for benchmarking ML pipelines, for example, written with batchflow.
Most of the work is done inside jupyter notebook so it's not very convenient to move pipelines to scripts at R&D stage but profiling is necessary.

I find log_sparse extremely useful to profile pipelines like that

my_dataset.pipeline()
              .load('/some/path')
              .do_something(use_lock=True)
              .do_something_else()

The pipeline is launched by a separate executor with a large number of service calls so VizTracer with log_sparse=False produces statistics also for that calls.
image

At the same time, only the total execution time of individual actions that can be run in parallel in threads for individual batches is of interest. Therefore, decorating the executable action helped a lot to make such timeline
image

from viztracer.

gaogaotiantian avatar gaogaotiantian commented on May 29, 2024

Do you have any chance to run some code before your decorator takes effect? If you can do tracer = VizTracer() before decorating, it should be registered globally and the decorator should be able to pick it up and do what you want. This would be a better workaround than making it always check in run-time.

from viztracer.

AlexeyKozhevin avatar AlexeyKozhevin commented on May 29, 2024

This is a more likely option, but I will have to place initialization before all imports, because the decorated methods may be in other modules.

Maybe it's worth making another decorator that will check at runtime only the first time the decorated function is called?

from viztracer.

gaogaotiantian avatar gaogaotiantian commented on May 29, 2024

Yeah that's an acceptable solutiion. We can add an optional argument dynamic_tracer_check=False to the decorator itself which can be set to True to force the returned function to check whether trace exists every time the function is called. This change requires docs change, I can work on it, or if you are willing to do it yourself, you are more than welcome.

from viztracer.

AlexeyKozhevin avatar AlexeyKozhevin commented on May 29, 2024

Yeap, I can do it

from viztracer.

AlexeyKozhevin avatar AlexeyKozhevin commented on May 29, 2024

I've add dynamic_tracer_check and started to test. Everything is okay with threads but I found that the context manager cannot work with multiprocessing. You have all necessary workarounds (like install_all_hooks) but they are located in VizUI/run_code.

What do you think is the most appropriate way to reuse all of this? Move to Viztracer class or create new class (some kind of executor)?

from viztracer.

gaogaotiantian avatar gaogaotiantian commented on May 29, 2024

multiprocessing only works with the command line interface at this point, that's another topic (not related to `log_sparse).

It's more than the hooks, it's about install hooks before multiprocessing starts working and collect data (wait for other processes). The current code is delicate and I'm not confident to make inline tracer work without breaking something.

As of now, that behavior would probably keep the way it is. All the monkey-patching methods normally have some extra requirements. So no multiprocessing support for inline tracer, only CLI at this time.

from viztracer.

AlexeyKozhevin avatar AlexeyKozhevin commented on May 29, 2024

I took into account your comments, made changes and also added some tests. Thanks to them, I found a situation to fix.
I will update the PR soon.

from viztracer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.