Giter Club home page Giter Club logo

Comments (7)

Barenboim avatar Barenboim commented on August 24, 2024

你好。我们是使用线程池的。计算线程池创建之后不会自动销毁的。

from workflow.

gitljh avatar gitljh commented on August 24, 2024

由于服务请求量很大,跑一个晚高峰过后,使用cat /proc/{进程号}/status 查看这个服务服务情况,发现线程数涨到大几万,这个有什么办法处理吗?
我看最新的commit:16686ba 有增加【[Enable increasing/decreasing compute threads】这个功能,是否可以通过decreasing来减少线程数量?

from workflow.

Barenboim avatar Barenboim commented on August 24, 2024

正常情况下,我们是不会动态增加线程的。也就是说,按照你的配置,只会存在208个线程。

除非你在网络线程里调用wait_group.wait(),这个操作一般是不应该存在的。如果你调用这个操作,我们为了保持你的活跃网络线程没有变化,会根据你最多同时等待的线程数来增加线程(最新master代码,也会动态减少)。但是,这个操作是不合理的,你应该把你的计算任务push_back到series里,而不是用wait group。

另外,你检查一下是不是你的代码会创建线程。

from workflow.

gitljh avatar gitljh commented on August 24, 2024

在网络线程里面,没有调用wait_group。
在WFGoTask的计算任务里面,我们是会创建标准库线程:

WFGoTask *gtask = WFTaskFactory::create_go_task("start_task", &UnionManager::asynStartTask, this, task_info, std::ref(ret));
gtask->start();
int UnionManager::syncStartTask(TaskInfo task_info){
    std::shared_ptr<IStreamTask> task = std::make_shared<StreamTask>();
    if (task.get() == nullptr){
        return APP_RET_MEM_ALLOC_FAIL;
    }

    task->setTaskExceptionCB(this);
    int ret = task->startTask(task_info, task_info.m_stream_id, task_info.m_try_num>0?task_info.m_try_num:300); 
    if (ret != APP_RET_OK){
        return ret;
    }
    setTask(task_info.m_stream_id, task);
    return APP_RET_OK;
}





ErrorCode startTask(const TaskInfo &task_info, std::string stream_id, int try_num_limit){
    ... ...
    m_thread = new std::thread(&TaskEx::asynRunTask, this);  //std::thread会在析构里面join,然后delete
    ... ...
    return APP_RET_OK;
}

from workflow.

Barenboim avatar Barenboim commented on August 24, 2024

不是,你自己new线程做什么😂

应该是你自己的线程,我们框架不会创建线程的。

另外,如果你是一个server的话,不太应该直接把一个go task用start()来启动,一般都是这样:

int process(WFHttpTask *task)
{
    gotask = WFTaskFactory::create_go_task(...);
    series_of(task)->push_back(go_task);
}

如果你没有使用到series,我也不清楚你是怎么实现异步的。难道你在process里直接等你的线程来唤醒?那就更加不对了。建议先看一下我们文档。

from workflow.

gitljh avatar gitljh commented on August 24, 2024

正常情况下,我们是不会动态增加线程的。也就是说,按照你的配置,只会存在208个线程。

除非你在网络线程里调用wait_group.wait(),这个操作一般是不应该存在的。如果你调用这个操作,我们为了保持你的活跃网络线程没有变化,会根据你最多同时等待的线程数来增加线程(最新master代码,也会动态减少)。但是,这个操作是不合理的,你应该把你的计算任务push_back到series里,而不是用wait group。

另外,你检查一下是不是你的代码会创建线程。

【(最新master代码,也会动态减少)】这里的动态减少,是网络线程、计算线程数量都会减少吗?需要上层应用显示调用吗?

另外,我想问一下:是否有api可以知道现在框架中的网络线程、计算线程数是多少?在官方demo示例中没有找到相关调用方法

from workflow.

Barenboim avatar Barenboim commented on August 24, 2024

正常情况下,我们是不会动态增加线程的。也就是说,按照你的配置,只会存在208个线程。
除非你在网络线程里调用wait_group.wait(),这个操作一般是不应该存在的。如果你调用这个操作,我们为了保持你的活跃网络线程没有变化,会根据你最多同时等待的线程数来增加线程(最新master代码,也会动态减少)。但是,这个操作是不合理的,你应该把你的计算任务push_back到series里,而不是用wait group。
另外,你检查一下是不是你的代码会创建线程。

【(最新master代码,也会动态减少)】这里的动态减少,是网络线程、计算线程数量都会减少吗?需要上层应用显示调用吗?

另外,我想问一下:是否有api可以知道现在框架中的网络线程、计算线程数是多少?在官方demo示例中没有找到相关调用方法

这个动态增加减少,只有在用我们WFFacilities::WaitGroup才有影响,你没有使用的话,可以完全忽略这个问题。

我们没有查询的接口,因为我们这些线程是不会变的。你的配置,就是208个线程,永远不会变。

你的std::thread用得不对,不会自己join的。而且,你完全没有必要自己创建线程。

from workflow.

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.