Code Monkey home page Code Monkey logo

Comments (5)

cloudwu avatar cloudwu commented on June 19, 2024

谢谢, 已修正.

这样做是因为在 IO 负荷大, 但业务简单的压力测试中, 我发现频繁 pthread_cond_signal (有系统调用)有比较大的开销.

skynet 可以在多于 1 的工作线程下正常运作. 所以不用急着唤醒 sleep 的工作线程 (只要有一个在工作就够了). 在网游的环境下, 大多数情况下都没有工作线程 sleep, 所以就无所谓唤醒. 只有在整个服务器闲置的情况下才会因为 IO 消息把服务器重新热起来. 如果 IO 消息很少, 那么唤醒多个也没有太多意义.

现在的修改是每 0.25 秒 (慢热), 由 timer 去尝试唤醒一次; IO 模块保留原来的设计, 只有在全部工作线程都 sleep 的时候才发送 pthread_cond_signal .

from skynet.

hlouis avatar hlouis commented on June 19, 2024

多谢说明,不过还是有一点不太理解:

假设我们的系统中有四个Service进行繁忙的周期性的CPU操作,他们都通过Skynet的Timer来驱动自己

如果按照之前的wakeup的调度,就算mq中有四个service有timer消息,也只能唤醒两根工作线程来进行工作,看起来有些不合理。

from skynet.

cloudwu avatar cloudwu commented on June 19, 2024

如果目前热起来的工作线程来不及干完 timer 交给它的事情的话, 那么 timer thread 里的 wakeup 就会唤醒新的工作线程了. 否则, 一两个工作线程也能及时处理掉四个 service 的 timer 事件.

之前那个的确是 bug, 我已经改了. ( timer thread 里应该是至少只要有一个工作线程在 sleep 就唤醒它, 而不是至多一个在 sleep)

from skynet.

cloudwu avatar cloudwu commented on June 19, 2024

我原本是想在 timer thread 里写: 如果有一个 worker thread 在 sleep 就发一个 signal, 结果想岔了, 就传了个 1, 变成了有一个没在 sleep 才发 signal .

from skynet.

hlouis avatar hlouis commented on June 19, 2024

呵呵,了解,多谢说明

On Sep 17, 2013, at 11:22 AM, 云风 [email protected] wrote:

我原本是想在 timer thread 里写: 如果有一个 worker thread 在 sleep 就发一个 signal, 结果想岔了, 就传了个 1, 变成了有一个没在 sleep 才发 signal .


Reply to this email directly or view it on GitHub.

from skynet.

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.