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

Interest in Additional LIbrary Features #67

Open
cwfitzgerald opened this issue Sep 24, 2018 · 8 comments
Open

Interest in Additional LIbrary Features #67

cwfitzgerald opened this issue Sep 24, 2018 · 8 comments

Comments

@cwfitzgerald
Copy link
Contributor

cwfitzgerald commented Sep 24, 2018

There are a couple of features that I am going to be developing for my personal project on a fork of this library, and I want to know if you would be interested in me upstreaming any/all of the features I'm planning on making. I'm not quite sure what you want the scope of this project to be. All of these would add on to the functionality, not replace it.

  • A type safe interface built on std::function.
  • A shared mutex.
  • A separate threadpool for IO blocking operations with api to call it.
  • Optional instrumentation of the fiber pool.
@martty
Copy link
Collaborator

martty commented Sep 24, 2018

Great!

I have already started working on a type safe interface (eg. lambda-as-a-task). I'll put it up in a PR by the end of the week. (I also made exploratory progress on coroutines and futures).

@cwfitzgerald
Copy link
Contributor Author

@martty This is meant as an internal implementation, so it isn't fully polished, but I have a working interface here: https://github.com/BVE-Reborn/fiber-tasking-library/tree/type-safe-interface. If you have a better idea for the interface, I might rewrite this perfect forwarding wrapper on top of your interface.

@RichieSams
Copy link
Owner

That sounds great!

For the blocking IO threadpool, is that like in the GDC talk, where they had a few threads to handle blocking IO, so-as to not tie up the main workers?

What kind of instrumentation are you thinking?

@cwfitzgerald
Copy link
Contributor Author

I feel bad for the poor souls watching this repo 😛

Yeah my plans are similar to the talk. I would have a pool of say... thread_count * 4 (by default) threads to do blocking IO in. There would be a call similar to my thread-safe-interface which would send off the data to be processed and have it wait on a counter that would be decremented by the worker thread.

The instrumentation would be similar to the talk as well. Not sure exactly what it would entail, but information about timings, task dependency stacks etc. I haven't really thought about it at this point.

@RichieSams
Copy link
Owner

That sounds good to me.

For the instrumentation, it would be really cool to have something like Remotery / Microprofile that understood fibers and task waiting / resuming. Perhaps we could add optional callback registering? So user / third party code would be notified when tasks are added, suspended, resumed, etc.

@cwfitzgerald
Copy link
Contributor Author

Seems feasible. I'll take a look at those librarys and see what I can do.

@martty
Copy link
Collaborator

martty commented Sep 28, 2018

@cwfitzgerald Please check #69 for a preliminary implementation of the type safe interface.

@vblanco20-1
Copy link

vblanco20-1 commented Oct 8, 2018

@RichieSams ive used remotery a bit with this lib in my project https://github.com/vblanco20-1/Rasterizer . There are huge flaws with remotery, as it can "choke" really, really hard. Even like that, i just added the logging inside the task function. It ends up looking like this, almost perfect scaling!!. (one frame of the rasterizer)

imagen

To capture this image, i had to add a throttle to my rendering of 1 second beetween frames (rendering takes 20 ms), becouse if i let it go at full speed, the sheer amount of events would destroy Remotery internal memory.
Another issue with remotery is that this library completely breaks it on the "wait for counter" function, due to the fiber switching.

What you comment with the callback sounds great maybe i could help with that. It could work great if you can just send the "name" of the task in the AddTasks/RunTasks function.
taskScheduler->AddTasks(numTasks, tasks, &taskEnd->counter, "rasterize_tile");

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

4 participants