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

Feat support cpu affinity for eat in linux #5

Conversation

Tomilla
Copy link
Contributor

@Tomilla Tomilla commented Jul 9, 2024

Hi Shawn,

1 New Feature:

  • Specify CPU Affinities for eat program process in Linux (Other systems still Work In Progress. As far as I know, Windows and macOS will share same Interface with Linux)

Resolved #1 Close #1

2 Introduce

Processor affinity, or CPU pinning or "cache affinity", enables the binding and unbinding of a process or a thread to a central processing unit (CPU) or a range of CPUs, so that the process or thread will execute only on the designated CPU or CPUs rather than any CPU.

3 Usage

3.1 One Full Core

Only run on first CPU Core #0

eat --cpu-affinities 0 -c 1

Screenshot from 2024-07-09 14-35-19

3.2 Multiple Full Cores

eat --cpu-affinities 0,1,2,3 -c 50%

Screenshot from 2024-07-09 14-36-09

Only run on CPU Core #4,5,6.

Notice #7 cpu affinity was declared, but not actually used by eat process.

eat --cpu-affinities 4,5,6,7 -c 3

Screenshot from 2024-07-09 14-31-48

3.3 Some Full Cores, One Part Core

// 8 cores * 0.92 = 7.36 cores ~= 7 full cores, 1 part core
eat --cpu-affinities 0,1,2,3,4,5,6,7 -c 92%

Screenshot from 2024-07-09 15-04-24

Thanks for you review 🤩

@Tomilla
Copy link
Contributor Author

Tomilla commented Jul 9, 2024

Note: due to 1.20 don't not generic and slices package. I need upgrade base golang version to 1.22 (Ref: Go 1.21 generics type inference: https://tip.golang.org/doc/go1.21#:~:text=slog.Handler%20implementations.-,New%20slices%20package,-The%20new%20slices)

@shawn-bluce shawn-bluce self-requested a review July 10, 2024 13:15
@shawn-bluce shawn-bluce merged commit fab0a83 into shawn-bluce:master Jul 17, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

指定占用哪个CPU核
2 participants