Comments (10)
Also I'll review the code when I got some time :)
from viztracer.
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.
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.
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
from viztracer.
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.
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.
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.
Yeap, I can do it
from viztracer.
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.
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.
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)
- Time.monotonic makes it impossible to line up distributed traces HOT 1
- NameError HOT 1
- `SNAPTRACE_TRACE_SELF` typo at `snaptrace.c` HOT 2
- JSONDecodeError in report_builder.py HOT 20
- vizviewer fails HOT 2
- command not found: vizviewer HOT 5
- vizobject/vizcounter not working for Inheritance HOT 3
- Bug: args that overlap with viztracer is lost in subprocess.Popen HOT 1
- Unable to use @trace_and_save with multiprocessing HOT 1
- VSCode extension shows blank screen on vscode remote HOT 9
- VsCode里右键选择Trace with Viztracer后报错 HOT 1
- Linux 上 VSCode extension 打开 viztracer 的结果文件出现问题 HOT 4
- No reminder of port conflict when using the parameter "--use_external_processor" HOT 1
- Clear `viztmp` file even if there's something wrong with trace report saving HOT 1
- Please provide Wheels for Apple Silicon HOT 5
- please provide conda package for the latest version of viztracer HOT 1
- Jupyter Support: Why not have a cell magic too HOT 1
- "Wait for child processes to finish, Ctrl+C to skip" forever loop and no response HOT 2
- inline viztracer cannot trace multiprocess HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viztracer.