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

Tracy and coroutines #936

Open
Sven-v-Beuningen opened this issue Dec 2, 2024 · 2 comments
Open

Tracy and coroutines #936

Sven-v-Beuningen opened this issue Dec 2, 2024 · 2 comments

Comments

@Sven-v-Beuningen
Copy link

I'm currently working on a c++20 coroutine based JobSystem.
The JobSystem schedules coroutines on multiple threads. Calls to co_await can suspend the current coroutine and the JobSystem schedules another coroutine on the same thread. Later on the scheduler returns to the co_awaited coroutine.
Because of this it can happen that a coroutine is suspended and resumed multiple times.
I tried to use Tracy with this system, but always get "Zone is ended twice" error.
Is there anything I can do about that, or does Tracy just not support using coroutines?

Thank you very much in advance!

@wolfpld
Copy link
Owner

wolfpld commented Dec 2, 2024

Please read about fibers in the manual.

@Sven-v-Beuningen
Copy link
Author

Thank you very much about the hin. I read the part about fibers in the documentation and gave it a try:

This is my main worker function. It graps a Job and executes/resumes it. As described in your documentation, I Added the TracyFiberEnter and TracyFiberLeave macros. I also defined TRACY_FIBERS

auto JobSystemWorker::workerFunction() -> void
{
    TracyFiberEnter(m_workerName.c_str());
    while (m_running)
    {
        auto job = std::move(getJob());
        if (job)
        {
            (*job)();
        }
    }
    TracyFiberLeave;
}

Unfortunately, this didn't change anything. As written in the documentation, I added TracyFiberEnter macros, everytime I resume a coroutine:

auto func() -> Job {
    TracyFiberEnter(JobSystem::GetCurrentWorker()->getName());
    UV_PERF_ZONE(EProfilingSystem::Render_1);
    co_return;
}

auto mainFunc() -> Job
{
    while (true)
    {
        UV_PERF_ZONE(EProfilingSystem::Render_1);
        co_await func();
        TracyFiberEnter(JobSystem::GetCurrentWorker()->getName());
        UV_PERF_FRAMEBREAK();
    }

    JobSystem::Stop();
    co_return;
}

But I still geht the "Zone ended twice" error. Did I miss something else?

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

No branches or pull requests

2 participants