Coder Social home page Coder Social logo

Comments (4)

VSadov avatar VSadov commented on May 24, 2024

Task.Factory.StartNew(body, TaskCreationOptions.LongRunning) starts a new thread because of LongRunning option.

Here we create threads:

            for (int i = 0; i < workers.Length; i++)
            {
                workers[i] = Task.Factory.StartNew(body, TaskCreationOptions.LongRunning);
            }

            stop_time = sw.ElapsedMilliseconds + time;

And here execution starts in all workers (which are all waiting for this event):

            e.Set();

The latency of an event is orders of magnitude faster than duration of one benchmark (3sec.), so
when a benchmark needs a particular degree of concurrency the above guarantees it quite reliably.

I do not think we have a problem here.

======= relevant code here:

private static long RunBenchmark(Action<int, int> action, int threads, int time)

from nonblocking.

VSadov avatar VSadov commented on May 24, 2024

For the tests - by default they run continuously and could be left running for hours.

While thread pool does not guarantee a particular concurrency mode, it appears to expose tests to all kind of random combinations (sequential or concurrent) and in practice catches problems really well.

from nonblocking.

nerai avatar nerai commented on May 24, 2024

Regarding LongRunning, I don't think the behavior of creating a new, separate thread is guaranteed:

LongRunning: Specifies that a task will be a long-running, coarse-grained operation involving fewer, larger components than fine-grained systems. It provides a hint to the TaskScheduler that oversubscription may be warranted. Oversubscription lets you create more threads than the available number of hardware threads. It also provides a hint to the task scheduler that an additional thread might be required for the task so that it does not block the forward progress of other threads or work items on the local thread-pool queue. [src]

from nonblocking.

VSadov avatar VSadov commented on May 24, 2024

Tasks appear to work as expected. I do not think we have a problem here.

from nonblocking.

Related Issues (10)

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.