What does cpu-pinning mean in context of KVM hypervisor with multiple virtual machines

1,038

Solution 1

CPU pinning ensures a VM will only get CPU time from a specific CPU or set of CPUs. Unless you have a very specific reason to pin, there usually is no need to do that.

Solution 2

I'm sure you can have a performance gain if you pin each VM to specific CPU cores, as well as restrict the hypervisor to one or two other cores.

That would allow your VM's to optimally benefit from the L1 and L2 caches which are CPU specific and they won't be bothered by interrupts from NIC's and storage controllers.

On the other hand I expect the hypervisor already makes an effort to mostly direct CPU events of the same virtual CPU to the same physical core and I doubt it would be a significant performance gain if you manually force something more strict.

The disadvantages of that are pretty obvious too, when you assign more cores to virtual guests than available physical cores are present it is unlikely your manual CPU pinning does a better job than the hypervisor. It will also be hell when you use live migrations.

Share:
1,038

Related videos on Youtube

Frankie
Author by

Frankie

Updated on September 18, 2022

Comments

  • Frankie
    Frankie almost 2 years

    I'm playing with REACT context trying to update a login from a Child component to an App component when I press the button on the Child component.

    Full code here.

    So there are two components : App and Child in the same file.

    Here is my UserContext with the login variable and the function to update the login (with loginUpdated)

    const UserContext = React.createContext({
        login: 'defaultLogin',
        updateLogin: (loginUpdated) => {}
    });
    

    In the App component, I've got my UserContext.Provider surrounding the Child component :

    class App extends React.Component {
        constructor(props) {
            super(props);
    
            this.appLoginUpdate = this.appLoginUpdate.bind(this); 
    
            this.state = {
                login: "AppLoginValue"
            }
        }
    
        appLoginUpdate(login) {
            console.log("1. appLoginUpdate method => login value: ", login)
    
            this.setState({
                login: login
            })
    
            console.log("2. appLoginUpdateLogin method after state update :", this.state.login)
        }
    
        render() {
            const contextValue = {
                login: "contextValueLogin",
                updateLogin: this.appLoginUpdate
            }
            return (
                <UserContext.Provider value={contextValue}>
                    <Child />
                </UserContext.Provider>
            );
        }
    }
    

    And finally I've got the Child component

    class Child extends React.Component {
        constructor(props) {
            super(props);
    
            this.handleClick = this.handleClick.bind(this);
        }
    
        static contextType = UserContext;
    
        handleClick() {
            this.context.updateLogin("ChildValueLogin")
        }
    
        render() {
            console.log("3. Context login value : ", this.context.login)
            return (
                <div>
                    <h1>{this.context.login}</h1>
                    <button onClick={this.handleClick}>UPDATE LOGIN</button>
                </div>
            )
        }
    }
    
    

    Before clicking on "UPDATE LOGIN" button, I've got this in the console :

    3. Context login value :  contextValueLogin 
    

    [ That's OK, this is the value given to contextValue.login in the App ]

    When a first click on the "UPDATE LOGIN" button, I've got this in the console :

    1. appLoginUpdate method => login value:  ChildValueLogin 
    

    [ That's OK, expected value for login argument ]

    2. appLoginUpdateLogin method after state update : AppLoginValue
    

    [ That's bad, this.state has not been updated ]

    3. Context login value :  contextValueLogin 
    

    [ That's bad too ]

    When I click again :

    1. appLoginUpdate method => login value:  ChildValueLogin
    

    [ OK again ]

    2. appLoginUpdateLogin method after state update : ChildValueLogin
    

    [ Now it's OK after second click ?! ]

    3. Context login value :  contextValueLogin
    

    [ Bad again, never updated ]

    I would like you to help me finding out what are my problems in this code please. Thank you for you help.

    • Michael Hampton
      Michael Hampton almost 10 years
      Do you really need to do CPU pinning?
    • Akshya11235
      Akshya11235 almost 10 years
      I was trying to measure performance of httperf if my VM has the http server running. without pinning I was seeing the httperf using the full nic bandwidth. But with pinning I saw a drop in performance. I wanted to understand what difference did the pinning make
  • David Corsalini
    David Corsalini almost 10 years
    I've seen performance drop on moderately loaded systems, when pinning was in use