!534 ffrt 同步

Merge pull request !534 from wenxingqi/master
This commit is contained in:
openharmony_ci 2024-11-19 13:05:13 +00:00 committed by Gitee
commit 6f425b80a2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 83 additions and 227 deletions

View File

@ -36,7 +36,7 @@ int SerialQueue::Push(QueueTask* task)
if (task->InsertHead() && !whenMap_.empty()) {
FFRT_LOGD("head insert task=%u in [queueId=%u]", task->gid, queueId_);
uint64_t headTime = (whenMap_.begin()->first > 0) ? whenMap_.begin()->first - 1 : 0;
whenMap_.insert({headTime, task});
whenMap_.insert({std::min(headTime, task->GetUptime()), task});
} else {
whenMap_.insert({task->GetUptime(), task});
}
@ -45,6 +45,11 @@ int SerialQueue::Push(QueueTask* task)
cond_.NotifyOne();
}
if (whenMap_.size() >= overloadThreshold_) {
FFRT_LOGW("[queueId=%u] overload warning, size=%llu", queueId_, whenMap_.size());
overloadThreshold_ += overloadThreshold_;
}
return SUCC;
}

View File

@ -39,6 +39,9 @@ public:
{
return ffrt_queue_serial;
}
// initial value of overload threshold is 16
uint32_t overloadThreshold_ = 16;
};
std::unique_ptr<BaseQueue> CreateSerialQueue(const ffrt_queue_attr_t* attr);

View File

@ -21,6 +21,14 @@ module_output_path = "ffrttest/"
gtest_public_external_deps = [ "googletest:gtest_main" ]
ffrt_ut_base_cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
ffrt_ut_base_deps = [ "../..:libffrt" ]
ffrt_ut_base_external_deps = [
@ -85,17 +93,12 @@ config("ffrt_test_config") {
ohos_unittest("frame_interval_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "frame_interval_test.cpp" ]
deps = ffrt_ut_base_deps
@ -111,17 +114,12 @@ ohos_unittest("frame_interval_test") {
ohos_unittest("deadline_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "deadline_test.cpp" ]
deps = ffrt_ut_base_deps
@ -137,17 +135,12 @@ ohos_unittest("deadline_test") {
ohos_unittest("task_ctx_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "task_ctx_test.cpp" ]
deps = ffrt_ut_base_deps
@ -163,17 +156,12 @@ ohos_unittest("task_ctx_test") {
ohos_unittest("cpu_monitor_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "cpu_monitor_test.cpp" ]
deps = ffrt_ut_base_deps
@ -189,17 +177,12 @@ ohos_unittest("cpu_monitor_test") {
ohos_unittest("cpuworker_manager_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "cpuworker_manager_test.cpp" ]
deps = ffrt_ut_base_deps
@ -215,17 +198,12 @@ ohos_unittest("cpuworker_manager_test") {
ohos_unittest("execute_unit_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "execute_unit_test.cpp" ]
deps = ffrt_ut_base_deps
@ -241,17 +219,12 @@ ohos_unittest("execute_unit_test") {
ohos_unittest("worker_thread_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "worker_thread_test.cpp" ]
deps = ffrt_ut_base_deps
@ -267,17 +240,12 @@ ohos_unittest("worker_thread_test") {
ohos_unittest("ut_coroutine") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_coroutine.cpp" ]
deps = ffrt_ut_base_deps
@ -293,17 +261,12 @@ ohos_unittest("ut_coroutine") {
ohos_unittest("ut_cpumonitor") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_cpumonitor.cpp" ]
deps = ffrt_ut_base_deps
@ -321,17 +284,12 @@ ohos_unittest("ut_cpumonitor") {
ohos_unittest("inherit_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/inherit_test.cpp" ]
deps = ffrt_ut_base_deps
@ -347,17 +305,12 @@ ohos_unittest("inherit_test") {
ohos_unittest("multi_workgroup_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "multi_workgroup_test.cpp" ]
deps = ffrt_ut_base_deps
@ -373,17 +326,12 @@ ohos_unittest("multi_workgroup_test") {
ohos_unittest("qos_convert_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "qos_convert_test.cpp" ]
deps = ffrt_ut_base_deps
@ -398,17 +346,12 @@ ohos_unittest("qos_convert_test") {
ohos_unittest("qos_interface_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "qos_interface_test.cpp" ]
deps = ffrt_ut_base_deps
@ -424,18 +367,13 @@ ohos_unittest("qos_interface_test") {
ohos_unittest("ut_cgroup_qos") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
"-DWITH_NO_MOCKER",
]
cflags_cc += ffrt_ut_base_cflags_cc
cflags_cc += [ "-DWITH_NO_MOCKER" ]
sources = [ "testcase/ut_cgroup_qos.cpp" ]
deps = ffrt_ut_base_deps
@ -451,17 +389,12 @@ ohos_unittest("ut_cgroup_qos") {
ohos_unittest("ut_condition") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_condition.cpp" ]
deps = ffrt_ut_base_deps
@ -477,17 +410,12 @@ ohos_unittest("ut_condition") {
ohos_unittest("ut_core") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_core.cpp" ]
deps = ffrt_ut_base_deps
@ -503,17 +431,12 @@ ohos_unittest("ut_core") {
ohos_unittest("ut_csync") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_csync.cpp" ]
deps = ffrt_ut_base_deps
@ -529,17 +452,12 @@ ohos_unittest("ut_csync") {
ohos_unittest("ut_deadline") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_deadline.cpp" ]
deps = ffrt_ut_base_deps
@ -555,17 +473,12 @@ ohos_unittest("ut_deadline") {
ohos_unittest("ut_dependency") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_dependency.cpp" ]
deps = ffrt_ut_base_deps
@ -581,17 +494,12 @@ ohos_unittest("ut_dependency") {
ohos_unittest("ut_execute_unit") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_execute_unit.cpp" ]
deps = ffrt_ut_base_deps
@ -607,17 +515,12 @@ ohos_unittest("ut_execute_unit") {
ohos_unittest("ut_ffrt_io") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_ffrt_io.cpp" ]
deps = ffrt_ut_base_deps
@ -633,17 +536,12 @@ ohos_unittest("ut_ffrt_io") {
ohos_unittest("ut_graphCheck") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_graphCheck.cpp" ]
deps = ffrt_ut_base_deps
@ -659,17 +557,12 @@ ohos_unittest("ut_graphCheck") {
ohos_unittest("ut_interval") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_interval.cpp" ]
deps = ffrt_ut_base_deps
@ -685,18 +578,13 @@ ohos_unittest("ut_interval") {
ohos_unittest("ut_loop") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
"-DWITH_NO_MOCKER",
]
cflags_cc += ffrt_ut_base_cflags_cc
cflags_cc += [ "-DWITH_NO_MOCKER" ]
sources = [ "testcase/ut_loop.cpp" ]
deps = ffrt_ut_base_deps
@ -712,17 +600,12 @@ ohos_unittest("ut_loop") {
ohos_unittest("ut_queue") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_queue.cpp" ]
deps = ffrt_ut_base_deps
@ -738,17 +621,12 @@ ohos_unittest("ut_queue") {
ohos_unittest("ut_rtg") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_rtg.cpp" ]
deps = ffrt_ut_base_deps
@ -764,17 +642,12 @@ ohos_unittest("ut_rtg") {
ohos_unittest("ut_scheduler") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_scheduler.cpp" ]
deps = ffrt_ut_base_deps
@ -790,17 +663,12 @@ ohos_unittest("ut_scheduler") {
ohos_unittest("ut_thread") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_thread.cpp" ]
deps = ffrt_ut_base_deps
@ -816,17 +684,12 @@ ohos_unittest("ut_thread") {
ohos_unittest("ut_mem") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
cflags_cc += [ "-DUSE_GTEST" ]
sources = [
@ -847,17 +710,12 @@ ohos_unittest("ut_mem") {
ohos_unittest("worker_manager_test") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "worker_manager_test.cpp" ]
deps = ffrt_ut_base_deps
@ -873,17 +731,12 @@ ohos_unittest("worker_manager_test") {
ohos_unittest("ut_queue_dump") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_queue_dump.cpp" ]
deps = ffrt_ut_base_deps
@ -899,17 +752,12 @@ ohos_unittest("ut_queue_dump") {
ohos_unittest("ut_dump") {
module_out_path = module_output_path
cflags_cc = []
configs = [ ":ffrt_test_config" ]
include_dirs = [ "../testfunc" ]
cflags_cc = [
"-frtti",
"-Xclang",
"-fcxx-exceptions",
"-std=c++11",
"-DFFRT_PERF_EVENT_ENABLE",
]
cflags_cc += ffrt_ut_base_cflags_cc
sources = [ "testcase/ut_dump.cpp" ]
deps = ffrt_ut_base_deps