Re: [PATCH 1/2] sched/fair: Record the average duration of a task
From: Madadi Vineeth Reddy
Date: Mon Aug 05 2024 - 00:39:20 EST
Hi Chen Yu,
On 30/06/24 18:39, Chen Yu wrote:
> Hi Mike,
>
> Thanks for your time and giving the insights.
>
> On 2024-06-26 at 06:21:43 +0200, Mike Galbraith wrote:
>> On Tue, 2024-06-25 at 15:22 +0800, Chen Yu wrote:
>>>
>>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>>> index 0935f9d4bb7b..7399c4143528 100644
>>> --- a/kernel/sched/core.c
>>> +++ b/kernel/sched/core.c
>>> @@ -4359,6 +4359,8 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
>>> p->migration_pending = NULL;
>>> #endif
>>> init_sched_mm_cid(p);
>>> + p->prev_sleep_sum_runtime = 0;
>>> + p->duration_avg = 0;
>>> }
>>
>> Beginning life biased toward stacking?
>>
>
> OK, so I should change the short_task() to skip the 0 duration_avg, to avoid
> task stacking in the beginning.
>
>>> DEFINE_STATIC_KEY_FALSE(sched_numa_balancing);
>>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>>> index 41b58387023d..445877069fbf 100644
>>> --- a/kernel/sched/fair.c
>>> +++ b/kernel/sched/fair.c
>>>
>>> @@ -6905,6 +6914,9 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
>>>
>>> dequeue_throttle:
>>> util_est_update(&rq->cfs, p, task_sleep);
>>> + if (task_sleep)
>>> + dur_avg_update(p);
>>> +
>>> hrtick_update(rq);
>>> }
>>>
>>
>> That qualifier looks a bit dangerous. Microbench components tend to
>> have only one behavior, but the real world goes through all kinds of
>> nutty gyrations, intentional and otherwise.
>>
>
> Understand. Unfortunately I don't have access to production environment
> so I have to rely on microbenchmarks and a OLTP to check the result. I
> get feedback from Abel that the former version of this patch brought
> benefit to some short tasks like Redis in the production environment[1].
> https://lore.kernel.org/lkml/36ba3b68-5b73-9db0-2247-061627b0d95a@xxxxxxxxxxxxx/
Since the discussion was about real-life workload performance, I ran the DayTrader
workload with three users and three instances. The results show no performance
regression, and a 1% performance gain was observed, which is within the standard
deviation.
Thanks and Regards
Madadi Vineeth Reddy
>
> I can launch a combination of microbenchmarks in parallel to check the impact.
>
>> The heuristics in the next patch seem to exhibit a healthy level of
>> paranoia, but these bits could perhaps use a tad more. Bad experiences
>> springs to mind when I stare at that - sleepers going hog, hogs meet
>> sleeping lock contention, preemption, sync hint not meaning much...