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

script/: add cpu-map.sh to aid manual selection of CPU cores for threads for profiling #57562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

perezjosibm
Copy link

This PR adds a new utility script

[script/cpu_map.sh]

Add a new tool to set the CPU core affinity for a group of threads within a process. This is useful when experimenting to set different groups of threads on different CPU cores.

Usage:
cpu-map.sh -p <process_PIDs comma separated> -n <process_Name> -g (optional) <by-group>

There are examples at the top of the script, which should make it easier to edit to suit for your own requirements.

  • The following defines four group of threads, and the CPU cores they should be bound to:
    declare -A thr_grp_map=([alien-store-tp]="4-7" [rocksdb]="4-7" [bstore]="4-7" [cfin]="4-7" )
  • The following indicates which CPU cores other threads not in the above groups should be bound to:
    free_cpu_avail="4-7"
  • The next sentence defines a regular expression for the thread names that correspond to the above groups:
    proc_group_re="alien-store-tp|rocksdb|bstore|cfin"
  • Finally, the following indicates not to change the affinity of the following group of threads:
    proc_ignore_re="crimson-osd|reactor|log|syscall"

This is an example of the execution and the resulting CPU core assignment:
cpu-map.sh -p $(pgrep crimson-osd) -g

Screenshot 2024-05-08 at 14 22 10

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

…ads for profiling

Signed-off-by: Jose J Palacios-Perez <perezjos@uk.ibm.com>
Copy link
Contributor

@athanatos athanatos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm mostly just missing a bit of clarity on how to actually use this script -- slightly more specific examples would probably take care of that. Generally, I think this is fine to put in scripts/ and will be useful.

# ! Ex.: ./cpu-map.sh -n scylla
# ! ./cpu-map.sh -n scylla -g
# ! ./cpu-map.sh -p "1362, 1049"
# ! ./cpu-map.sh -p 32 -g
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's lifted from seastar.git scripts/seastar-cpu-map.sh. That's fine, but let's update the examples to suggest how to use it specifically with crimson-osd or ceph-osd?

proc_group_re="alien-store-tp|rocksdb|bstore|cfin"

# Regex to ignore:
proc_ignore_re="crimson-osd|reactor|log|syscall"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intention for the user to uncomment one of these sections depending on what they are doing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, precisely, that is the intention. I thought that adding command line options at the script would make it confusing.
I'll add further examples asap.

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