Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is ALFA 0.08 and MIN_DT 20? #88

Open
sam6666666 opened this issue Jul 17, 2019 · 1 comment
Open

Why is ALFA 0.08 and MIN_DT 20? #88

sam6666666 opened this issue Jul 17, 2019 · 1 comment

Comments

@sam6666666
Copy link

This is the process I organized. I wonder why ALFA chooses 0.08 and MIN_DT 20?
command: cpulimit -i -l=3
While (1)
{
/ / find the process by pid
Check to see if the cpulimit process is the same. Do not limit yourself

// limit function
Limit_process (pid, limit, include_children);
}

Limit_process (pid, limit, include_children)
{
// all child processes of the pid are added to the hash table with the pid as the key

// read the proc information /proc/stat of the child process pid

/ *

  • cputime
  • starttime
  • /

Update_process_group -> cpu_usage for each polling calculation process
Tmp_process is the currently reread process information

P is the process information for the last process

Double sample = 1.0 * (tmp_process.cputime-p-> cputime)/dt;
Calculate CPU utilization based on two CPU usage times

The first time, p->cpu_usage = sample

After this, p->cpu_usage = (1.0-0.08) * p->cpu_usage + 0.08 * sample;

CPU usage start limit ->

Double pcpu = 1;
// traverses the list of sub-processes and statistics the total CPU utilization of sub-processes (non-statistics less than 0)
Pcpu + = p - > cpu_usage;

If the CPU usage of the sub-process is less than 0 pcpu = -1
For the first time:
Pcap = 0.05
Workingrate = 0.05
Twork. tv_nsec = 100000 * 0.05 * 1000; // CPU usage usage time
After:
Workinfiring = MIN(workinfiring/pcpu * 0.05, 1);
Twork.tv_nsec = 100000 * 1000 * workingrate; // statistics the actual time the process has been running
Tsleep. tv_nsec = 100000 * 1000 - twork.tv_nsec; // the time the process should sleep

// traversal sends SIGCONT signal to the process to make it run

// sleep twork time to keep the process running for so long

The gettimeofday (& the startwork, NULL);

Nanosleep (& twork, NULL);

The gettimeofday (& endwork, NULL);

//nanosleep may wake up in the middle and calculate the actual running time

Workingtime = timediff (& endwork, & the startwork);

// too much sleep is bad
Long delay = workingtime - twork.tv_nsec/1000;

// traversal process sends SIGSTOP signal

// sleep tsleep time, let the process stop running
}

@sam6666666
Copy link
Author

Sorry about the typography。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant