What are the benefits of using longer/shorter periods in cpu.cfs_period_us?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1














When you want to limit CPU time per process, you can do it via cgroups. There are two parameters that can do the job: cpu.cfs_period_us and cpu.cfs_quota_us.



There's some info on the parameters here:




  • cpu.cfs_period_us: The duration in microseconds of each scheduler period, for bandwidth decisions. This defaults to 100000us or 100ms.
    Larger periods will improve throughput at the expense of latency,
    since the scheduler will be able to sustain a cpu-bound workload for
    longer. The opposite of true for smaller periods. Note that this only
    affects non-RT tasks that are scheduled by the CFS scheduler.

  • cpu.cfs_quota_us: The maximum time in microseconds during each cfs_period_us in for the current group will be allowed to run. For
    instance, if it is set to half of cpu_period_us, the cgroup will
    only be able to peak run for 50 % of the time. One should note that
    this represents aggregate time over all CPUs in the system.
    Therefore, in order to allow full usage of two CPUs, for instance,
    one should set this value to twice the value of cfs_period_us.



Let's say I want to limit a process to 1 CPU core. This can be done in the following ways:



cpu.cfs_quota_us 1.000.000
cpu.cfs_period_us 1.000.000


vs.



cpu.cfs_quota_us 100.000
cpu.cfs_period_us 100.000


vs.



cpu.cfs_quota_us 10.000
cpu.cfs_period_us 10.000


What's the difference between the three options? Let's say I have a Firefox process, what cpu.cfs_period_us is better for it -- longer or shorter and why?










share|improve this question


























    1














    When you want to limit CPU time per process, you can do it via cgroups. There are two parameters that can do the job: cpu.cfs_period_us and cpu.cfs_quota_us.



    There's some info on the parameters here:




    • cpu.cfs_period_us: The duration in microseconds of each scheduler period, for bandwidth decisions. This defaults to 100000us or 100ms.
      Larger periods will improve throughput at the expense of latency,
      since the scheduler will be able to sustain a cpu-bound workload for
      longer. The opposite of true for smaller periods. Note that this only
      affects non-RT tasks that are scheduled by the CFS scheduler.

    • cpu.cfs_quota_us: The maximum time in microseconds during each cfs_period_us in for the current group will be allowed to run. For
      instance, if it is set to half of cpu_period_us, the cgroup will
      only be able to peak run for 50 % of the time. One should note that
      this represents aggregate time over all CPUs in the system.
      Therefore, in order to allow full usage of two CPUs, for instance,
      one should set this value to twice the value of cfs_period_us.



    Let's say I want to limit a process to 1 CPU core. This can be done in the following ways:



    cpu.cfs_quota_us 1.000.000
    cpu.cfs_period_us 1.000.000


    vs.



    cpu.cfs_quota_us 100.000
    cpu.cfs_period_us 100.000


    vs.



    cpu.cfs_quota_us 10.000
    cpu.cfs_period_us 10.000


    What's the difference between the three options? Let's say I have a Firefox process, what cpu.cfs_period_us is better for it -- longer or shorter and why?










    share|improve this question
























      1












      1








      1







      When you want to limit CPU time per process, you can do it via cgroups. There are two parameters that can do the job: cpu.cfs_period_us and cpu.cfs_quota_us.



      There's some info on the parameters here:




      • cpu.cfs_period_us: The duration in microseconds of each scheduler period, for bandwidth decisions. This defaults to 100000us or 100ms.
        Larger periods will improve throughput at the expense of latency,
        since the scheduler will be able to sustain a cpu-bound workload for
        longer. The opposite of true for smaller periods. Note that this only
        affects non-RT tasks that are scheduled by the CFS scheduler.

      • cpu.cfs_quota_us: The maximum time in microseconds during each cfs_period_us in for the current group will be allowed to run. For
        instance, if it is set to half of cpu_period_us, the cgroup will
        only be able to peak run for 50 % of the time. One should note that
        this represents aggregate time over all CPUs in the system.
        Therefore, in order to allow full usage of two CPUs, for instance,
        one should set this value to twice the value of cfs_period_us.



      Let's say I want to limit a process to 1 CPU core. This can be done in the following ways:



      cpu.cfs_quota_us 1.000.000
      cpu.cfs_period_us 1.000.000


      vs.



      cpu.cfs_quota_us 100.000
      cpu.cfs_period_us 100.000


      vs.



      cpu.cfs_quota_us 10.000
      cpu.cfs_period_us 10.000


      What's the difference between the three options? Let's say I have a Firefox process, what cpu.cfs_period_us is better for it -- longer or shorter and why?










      share|improve this question













      When you want to limit CPU time per process, you can do it via cgroups. There are two parameters that can do the job: cpu.cfs_period_us and cpu.cfs_quota_us.



      There's some info on the parameters here:




      • cpu.cfs_period_us: The duration in microseconds of each scheduler period, for bandwidth decisions. This defaults to 100000us or 100ms.
        Larger periods will improve throughput at the expense of latency,
        since the scheduler will be able to sustain a cpu-bound workload for
        longer. The opposite of true for smaller periods. Note that this only
        affects non-RT tasks that are scheduled by the CFS scheduler.

      • cpu.cfs_quota_us: The maximum time in microseconds during each cfs_period_us in for the current group will be allowed to run. For
        instance, if it is set to half of cpu_period_us, the cgroup will
        only be able to peak run for 50 % of the time. One should note that
        this represents aggregate time over all CPUs in the system.
        Therefore, in order to allow full usage of two CPUs, for instance,
        one should set this value to twice the value of cfs_period_us.



      Let's say I want to limit a process to 1 CPU core. This can be done in the following ways:



      cpu.cfs_quota_us 1.000.000
      cpu.cfs_period_us 1.000.000


      vs.



      cpu.cfs_quota_us 100.000
      cpu.cfs_period_us 100.000


      vs.



      cpu.cfs_quota_us 10.000
      cpu.cfs_period_us 10.000


      What's the difference between the three options? Let's say I have a Firefox process, what cpu.cfs_period_us is better for it -- longer or shorter and why?







      kernel cpu cgroups






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 17 at 14:01









      Mikhail Morfikov

      4,364124471




      4,364124471




















          1 Answer
          1






          active

          oldest

          votes


















          1





          +100









          As the quote says lower number give lower latency. A process does not have to wait long before it is scheduled: Every process gets a turn, soon. However there is more re-scheduling overhead: Every time the time runs out, and there are other processes ready to run, there is a re-schedule.



          Re-scheduling involves saving all registers on the stack, saving the stack-pointer into the task-control-block, switching task-control-block, disabling/enabling parts of the virtual-page-table, reloading the stack-pointer, and restoring the registers. It can also cause more cache misses. So in short things run slower.



          For long-running non-interactive tasks a longer scheduler period is better. The batch scheduler has a longer scheduler period, and runs at a lower priority than the standard interactive scheduler.






          share|improve this answer




















          • So basically, for internet browsers it's better to use 1s period?
            – Mikhail Morfikov
            2 days ago










          • If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
            – ctrl-alt-delor
            2 days ago










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489481%2fwhat-are-the-benefits-of-using-longer-shorter-periods-in-cpu-cfs-period-us%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1





          +100









          As the quote says lower number give lower latency. A process does not have to wait long before it is scheduled: Every process gets a turn, soon. However there is more re-scheduling overhead: Every time the time runs out, and there are other processes ready to run, there is a re-schedule.



          Re-scheduling involves saving all registers on the stack, saving the stack-pointer into the task-control-block, switching task-control-block, disabling/enabling parts of the virtual-page-table, reloading the stack-pointer, and restoring the registers. It can also cause more cache misses. So in short things run slower.



          For long-running non-interactive tasks a longer scheduler period is better. The batch scheduler has a longer scheduler period, and runs at a lower priority than the standard interactive scheduler.






          share|improve this answer




















          • So basically, for internet browsers it's better to use 1s period?
            – Mikhail Morfikov
            2 days ago










          • If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
            – ctrl-alt-delor
            2 days ago















          1





          +100









          As the quote says lower number give lower latency. A process does not have to wait long before it is scheduled: Every process gets a turn, soon. However there is more re-scheduling overhead: Every time the time runs out, and there are other processes ready to run, there is a re-schedule.



          Re-scheduling involves saving all registers on the stack, saving the stack-pointer into the task-control-block, switching task-control-block, disabling/enabling parts of the virtual-page-table, reloading the stack-pointer, and restoring the registers. It can also cause more cache misses. So in short things run slower.



          For long-running non-interactive tasks a longer scheduler period is better. The batch scheduler has a longer scheduler period, and runs at a lower priority than the standard interactive scheduler.






          share|improve this answer




















          • So basically, for internet browsers it's better to use 1s period?
            – Mikhail Morfikov
            2 days ago










          • If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
            – ctrl-alt-delor
            2 days ago













          1





          +100







          1





          +100



          1




          +100




          As the quote says lower number give lower latency. A process does not have to wait long before it is scheduled: Every process gets a turn, soon. However there is more re-scheduling overhead: Every time the time runs out, and there are other processes ready to run, there is a re-schedule.



          Re-scheduling involves saving all registers on the stack, saving the stack-pointer into the task-control-block, switching task-control-block, disabling/enabling parts of the virtual-page-table, reloading the stack-pointer, and restoring the registers. It can also cause more cache misses. So in short things run slower.



          For long-running non-interactive tasks a longer scheduler period is better. The batch scheduler has a longer scheduler period, and runs at a lower priority than the standard interactive scheduler.






          share|improve this answer












          As the quote says lower number give lower latency. A process does not have to wait long before it is scheduled: Every process gets a turn, soon. However there is more re-scheduling overhead: Every time the time runs out, and there are other processes ready to run, there is a re-schedule.



          Re-scheduling involves saving all registers on the stack, saving the stack-pointer into the task-control-block, switching task-control-block, disabling/enabling parts of the virtual-page-table, reloading the stack-pointer, and restoring the registers. It can also cause more cache misses. So in short things run slower.



          For long-running non-interactive tasks a longer scheduler period is better. The batch scheduler has a longer scheduler period, and runs at a lower priority than the standard interactive scheduler.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 23 at 22:27









          ctrl-alt-delor

          10.8k41957




          10.8k41957











          • So basically, for internet browsers it's better to use 1s period?
            – Mikhail Morfikov
            2 days ago










          • If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
            – ctrl-alt-delor
            2 days ago
















          • So basically, for internet browsers it's better to use 1s period?
            – Mikhail Morfikov
            2 days ago










          • If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
            – ctrl-alt-delor
            2 days ago















          So basically, for internet browsers it's better to use 1s period?
          – Mikhail Morfikov
          2 days ago




          So basically, for internet browsers it's better to use 1s period?
          – Mikhail Morfikov
          2 days ago












          If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
          – ctrl-alt-delor
          2 days ago




          If you want it to be laggy, then yes. The higher the number the longer the latency. With 1s, you will wait on average ½ a second, for a process. There are some caveats thought. If there are fewer processes than processor cores, then there is no preemption (this number has no effect). If an event comes in, then it will most likely trigger a preemption, because of dynamic priority (so number has no effect). Anything with animation may become stutterey. You may see other effects.
          – ctrl-alt-delor
          2 days ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f489481%2fwhat-are-the-benefits-of-using-longer-shorter-periods-in-cpu-cfs-period-us%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay