Code Monkey home page Code Monkey logo

Comments (4)

beef9999 avatar beef9999 commented on May 18, 2024

The context switch latency varies from 10 to 20 nano seconds depending how many coroutines you are running with.

We already have a test case for this.

TEST(Perf, ThreadSwitch)
{
test_thread_switch(10, 64 * 1024);
return;
const uint64_t stack_size = 8 * 1024 * 1024;
LOG_INFO(VALUE(stack_size));
test_thread_switch(2, stack_size);
test_thread_switch(10, stack_size);
test_thread_switch(100, stack_size);
test_thread_switch(1000, stack_size);
test_thread_switch(10000, stack_size);
test_thread_switch(100000, stack_size);
for (uint64_t ss = 5; ss <= 13; ++ss)
{
test_thread_switch(100000, (1<<ss) * 1024);
}
}

You can run it on your environment.

from photonlibos.

beef9999 avatar beef9999 commented on May 18, 2024

But I wonder why context switch is what you are concerned. It doesn't weigh too much in the whole IO process, only a small portion, I believe.

Can you describe your scenario?

from photonlibos.

jiangdongzi avatar jiangdongzi commented on May 18, 2024

10 to 20 nano seconds

wonderful, can not believe, as I know the bthread which is a coroutine in brpc context switch time is 2~3 us..........

from photonlibos.

 avatar commented on May 18, 2024

But I wonder why context switch is what you are concerned. It doesn't weigh too much in the whole IO process, only a small portion, I believe.

Can you describe your scenario?

high frenquency trading. it is latency sensitive.

from photonlibos.

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.