[SOLVED] How to limit cpu usage by makepkg?

I tried
cpulimit -l 30 makepkg
but the cpu usage still reaches 100% + 100% due to conky (i have 2 core cpu). OK, I've found out that cpulimit does not restrict child processes but cgroup is promised to do that. So I installed it from AUR and did the following:
sudo systemctl enable cgconfig
sudo systemctl start cgconfig
sudo cgcreate -t my_name:my_name -a my_name:my_name -g memory,cpu:my_build
sudo echo 100000000 > /sys/fs/cgroup/memory/my_build/memory.limit_in_bytes
sudo echo 300 > /sys/fs/cgroup/cpu/my_build/cpu.shares
cgexec -g 'memory,cpu:my_build' makepkg
But cpu usage is nevertheless 100% + 100%.
Am I doing something wrong? And how to fix it?
Last edited by Next7 (2015-01-16 00:40:18)

I've found the solution for my problem. First of all "cpu.shares" parameter is useless for one task and one cgroup which is my case since it specifies a relative share of CPU among different cgroups.
So for my purpose the following parameters are needed: "cpu.cfs_period_us" and "cpu.cfs_quota_us". The execution of the following commands resulted in 10% + 10% CPU load.
echo 1000000 > /sys/fs/cgroup/cpu/my_build/cpu.cfs_period_us
echo 200000 > /sys/fs/cgroup/cpu/my_build/cpu.cfs_quota_us
And there's another important point: "cgexec" command should be executed with option "--sticky" to restrict child processes.
cgexec -g memory,cpu:my_build --sticky makepkg

Similar Messages

  • How to limit CPU usage on webcam stream handling?

    Hi, I am working on a robotics project where I use Java and JMF for image processing which is passed through JNI to OpenCV. My project pages are at: http://robot.lonningdal.net
    I am having problems with performance - the VIA CN13000 board is not exactly a racer, but a good and cheap alternative for robotics projects. The two main CPU consumers are speech recognition and webcamera stream handling.
    After some profiling I see that 50% the CPU is busy just decoding the stream where I discard almost all the pictures because my robot really only needs 1 frame per second to operate. I have looked up the JMF samples and found that you could adjust the framerate, but this doesnt work on my Logitech Pro 4000. If I could only limit the amount of pictures the webcamera sent down the stream I would free quite a lot of CPU resources.
    So my questions are, can anyone recommend a webcamera that does allow me to set this framerate through JMF to limit the actual stream from the camera? (important not to confuse this with adjusting visual framerate which actually just discards pictures). Or is there an alternative API I can use to grab single images if webcameras support this feature? Its important that this doesnt have a lot of overhead processing required per picture but that I can e.g. do a getImage() call to the API and it gets the image immediately.
    Any help would be greatly appreciated. Thank you.

    Hi John,
    I saw your update to my original thread in
    http://forum.java.sun.com/thread.jspa?threadID=570463&start=0&tstart=0
    I'm always glad to hear people using the code :-)
    You can set the framerate of that JMF captures the video stream, in the VideoFormat object.
    I've had some success with this approach before.
    So, assuming you still kept the setFormat() method from my code, here's a simple hard coded modification, where you set the framerate in the code.
    Ps. just curious, whereabouts you are in the world ?
    regards,
    Owen
    public void setFormat ( VideoFormat selectedFormat )
            if ( formatControl != null )
                player.stop();
                currentFormat = selectedFormat;
    replace with
    public void setFormat ( VideoFormat selectedFormat )
            float frameRate = 2.0f;   // 2 frames per second, alter as you wish
            if ( formatControl != null )
                player.stop();
               VideoFormat selectedFormatPlusFrameRate = new VideoFormat(selectedFormat.getEncoding(),
                                                    selectedFormat.getSize(),
                                                    selectedFormat.getMaxDataLength(),
                                                    selectedFormat.getDataType(),
                                                    frameRate);
                currentFormat = selectedFormatPlusFrameRate;Edited posted code, had commented out player.stop(), but you really do need that.

  • How to monitor CPU usage and performance on a Hyper-V server with several VM's

    I have a server that is running Windows 2008 64 bit Hyper-V, with 8 gigs of RAM and Intel Xeon X3440 @ 2.53 Ghz, which gives me 8 logical cores in the performance monitor on the host system.
    I have set up three Virtual Machines, all running Windows 2008 32 bit.
    Build server, running Team City
    Staging server
    SQL Server, running SQL Server 2005
    I have some troubles with the setup in that the host monitor remains responsive at all times, even though the VM's are seemingly working at 100% cpu and are very sluggish and unresponsive. (I have asked a separate question about that.)
    So the question here is: What is the best way to monitor how the physical CPU's are actually utilized? The reason I am asking is that I am being told that i cannot reliably use the task manager to monitor CPU usage in a VM.

    First, you have to remember that in Hyper-V that the "host" is called a parent partition and it really just like a virtualized guest with special permissions and roles. Just like any other child/guest, when you open up Task Manager, you can not see the CPU
    usage of the other children on the server.
    Ben Armstrong has a good explanation of this here:http://blogs.msdn.com/virtual_pc_guy/archive/2008/02/28/hyper-v-virtual-machine-cpu-usage-and-task-manager.aspx
    To summarize his post, you need to check three things to get an accurate picture of CPU utilization:
    View the CPU usage on each guest - this is available through Hyper-V Manager or Performance Monitor.
    CPU usage due to context switching - this is the perfmon counter called % Hypervisor Run Timeunder Hyper-V Hypervisor Virtual Processor
    Child partition worker process - vmwp.exe running on the parent partition (1 per child). This handles Hyper-V operations like saving
    state.

  • Limit CPU Usage

    I have a swing program that creates a number of rather large html files in a loop, around 50kb each. While the program is writing the files my CPU Usage stays at a constant 100%. I feel like this is a bad thing. Any way to limit this, or any insight that will make me feel better about what's going on? I'm running Windows 2K Professional. Thanks.

    my computer has 256mb of RAM, and is a Pentium 4. The code is a few nested for loops that ouptut 12 large dynamic html pages, picking data stored out of double[][] arrays. There is definitely a lot of data stored in memory, but memory is cheap right?
    I basically want to know the risks of having a program that demands so much CPU usage during execution. The CPU Usage is at 100% for less than 10 seconds while the files are written. Is this bad on the computer? will it cause computers problems with less memory and processor speed? A broad answer would be fine.

  • How to decrease CPU usage when using multiple threads?

    I am using vb.net , .NetFramework 2.0 . 
    My application gets live stock prices from google and updates stocks in database each 10 seconds.
    I get this code for  multithreading. When application starts updating stocks in database(about 200 stocks) , the update takes up to 3 seconds but it increase CPU usage from 10 % to 70 % or 80 %.
    What is the best way to to update database without getting CPU increase to high level?
    I observed that all threads works at the same time. how to make each thread wait until the second ends?
    This is my code. The problem is in function updateThreaded2().
    Please I need quick help. Thanks
    Public Function Update2(ByVal l As SortableBindingList(Of NewStockList)) As Long
    res = 0
    UThread = New System.Threading.Thread(AddressOf UpdateThreaded2)
    If Me.URunning = True Then
    Else
    Try
    Me.URunning = True
    Interlocked.Exchange(Me.UCount, 0) 'threadsafe method of assigning static value
    Interlocked.Exchange(Me.UDone, 0) 'threadsafe method of assigning static value
    UThread.Priority = Threading.ThreadPriority.BelowNormal
    UThread.IsBackground = True
    UThread.Start(l)
    Return 0
    Catch ex As Exception
    End Try
    End If
    End Function
    Private Sub UpdateThreaded2(ByVal l As SortableBindingList(Of NewStockList))
    Dim i As Integer = 0
    Dim threadcount As Integer = Math.Min(Me.MaxThreads, Me.Stocks.Count)
    Dim threads(threadcount - 1) As SUTC
    Try
    While i < Me.Stocks.Count
    For j As Integer = 0 To threadcount - 1
    If threads(j) Is Nothing Then
    If i < Me.Stocks.Count Then
    threads(j) = New SUTC(Me.Stocks(i), Me.DefaultService, AdjustSplits, Use20Minutes, l)
    threads(j).Thread.Priority = Threading.ThreadPriority.BelowNormal
    threads(j).Thread.IsBackground = True
    threads(j).Thread.Start()
    i += 1
    End If
    ElseIf threads(j).UpdateState = 0 Then
    If i < Me.Stocks.Count Then
    SecUpd(j) = Me.Stocks(i).symbol
    threads(j) = New SUTC(Me.Stocks(i), Me.DefaultService, AdjustSplits, Use20Minutes, l)
    threads(j).Thread.Priority = Threading.ThreadPriority.BelowNormal
    threads(j).Thread.IsBackground = True
    threads(j).Thread.Start()
    i += 1
    End If
    End If
    Next
    Dim running As Boolean = True
    While running
    For j As Integer = 0 To threadcount - 1
    If threads(j).UpdateState = 0 Then
    Thread.Sleep(10)
    running = False
    SecUpd(j) = ""
    Interlocked.Increment(UDone) 'threadsafe method of incrementing a variable by 1
    Interlocked.Exchange(UCount, UCount + threads(j).UpdateCount) 'Threadsafe method for assigning a value
    End If
    Next
    End While
    End While
    Dim pending As Integer = threadcount
    Dim tempcount As Integer = 0
    Dim oldcount As Integer = UCount
    While pending > 0
    pending = threadcount
    tempcount = 0
    For i = 0 To threadcount - 1
    If threads(i).UpdateState = 0 Then
    SecUpd(i) = ""
    pending -= 1
    tempcount += threads(i).UpdateCount
    Thread.Sleep(10)
    End If
    Next
    Interlocked.Exchange(UDone, Me.Stocks.Count - pending) 'Threadsafe method for assigning a value
    Interlocked.Exchange(UCount, oldcount + tempcount) 'Threadsafe method for assigning a value
    End While
    Me.URunning = False
    Catch ex As System.Threading.ThreadAbortException 'handle abort correctly
    Dim pending As Integer = threadcount
    Dim tempcount As Integer = 0
    Dim oldcount As Integer = UCount
    While pending > 0
    pending = threadcount
    tempcount = 0
    For i = 0 To threadcount - 1
    If threads(i).UpdateState = 0 Then
    SecUpd(i) = ""
    pending -= 1
    tempcount += threads(i).UpdateCount
    End If
    Next
    Interlocked.Exchange(UDone, Me.Stocks.Count - pending) 'Threadsafe method for assigning a value
    Interlocked.Exchange(UCount, oldcount + tempcount) 'Threadsafe method for assigning a value
    End While
    End Try
    End Sub

    When the market is opened, stock prices changed every 500 ms . You can see this change on google finance.
    I figured as much, but my thoughts are that if you can somehow find a way to make your program more event driven, then it may be possible to reduce unnecessary looping...
    “If you want something you've never had, you need to do something you've never done.”
    Don't forget to mark
    helpful posts and answers
    ! Answer an interesting question? Write a
    new article
    about it! My Articles
    *This post does not reflect the opinion of Microsoft, or its employees.

  • How to watch CPU usage of a long running process?

    Hi Gurus,
    I have a daemon type process that handles transactions. The transactions typically completes in less than a second. I would like to find out the CPU usage of the transactions. I am looking for something that allow me to watch the CPU usage of a process so that I can look for a spike when the transaction happens.
    Regular monitoring tools do not go down to sub-second granularity and cannot track specific process. Is there any Dtrace script for the job?
    Thanks,
    Anthony

    I am a newbie with dtrace, but I think that this might work.
    Start the script with script.d -c "demon args"
    The script would be of the type
    #!/usr/sbin/dtrace -s
    #pragma D option quiet
    pid$target:demon::entry
    /probefunc == transproc/
        self->ts[probefunc] = timestamp;
    pid$target:demon::return
    /self->ts[probefunc]/
        @func_time[probefunc] = sum(timestamp - self->ts[probefunc]);
    }

  • How to get CPU usage in the app?

    Is there any api that can get CPU usage through the code in an iphone app, thanks.

    Maybe you could use getloadavg():
    double la[3];
    getloadavg(la, 3);
    NSLog(@"%f - %f - %f", la[0], la[1], la[2]);

  • How to maximize cpu usage

    this is about an app that i use, not one i am developing, i am just trying to see if i can help out the developer or see if he has really tried 'everything' to optimize the app. This app does some heavy duty signal processing, it receives a very high speed
    usb data stream from a custom device, it uses about as much of the usb 2.0 bandwidth as it can passing in pre-processed spectrum sampes. Then the computer side app takes that and does more processing to find and extract the data that it is supposed to work
    on. I am running it on a win8x64, I7 box with one socket, 4 cores, virtualization enabled, and 8 logical processors, 8gb ram and nothing else doing anything significant... the app only takes about 50% of the cpu time even though it is not finishing processing
    one block of data before the next arrives, this results in it automatically cutting back on the data decoders to process fewer signals until it can complete the processing before the next data arrives.  I am watching the cpu usage in the task manager
    or the resource monitor or the performance monitor and see about the same thing, but i suspect that the cpu is actually busier than those are showing, for instance if i show the kernal time in the task manager it seems to be hanging about 25%, does that
    account for receiving the usb data and putting it in memory?  or would that be done by hardware and not require cpu cycles??  is there any way to monitor background activity that might be using the rest of the cpu time?  the developer says
    he tried all sorts of things to get higher cpu usage but couldn't get it much higher, even if running the threads in real time priority.  are there any unusual pitfalls or built in limitiations??

    Well you are asking us to do the dev's job while you don't even know what the job is. If the dev needs help (a big if, it seems the dev knows what he/she is doing) then the dev can ask here with specific goals (e.g. what part of program can be paralleled
    to utilize idle CPUs), with details about the architecture of the program (which you don't have).
    Also such rewriting comes with risks of breaking stuff that are already working besides labor cost. The dev may decide it is not worth the rewriting if the cost is too high compared
    benefits to the user, just saying. 
    Visual C++ MVP

  • How to reduce CPU usage when working in Logic Pro and Kontakt5

    Hello All,
    I have a MacBook Pro 15" early 2011 2.0 GHZ. My main acitivity is making music with my macbook pro. I am using Logic Pro 9 in combination with Kontakt 5.
    I want to get some suggestions in the setup so I can reduce the usage of the CPU. By the way I have upgraded my system with a SSD 256GB , 16GB RAM and have removed the optical drive and installed the the previous factory set HD in the optical bay. I have placed the samples of the Kontakt 5 in the HD so I have enough space on my SSD to run the progrmas fast and smooth !
    If possible give your advise on an optimum setup such as reachanaling the sounds through BUS to AUX channels and other methods in order to reduce the CPU usage. You may even post some good links where I can find more info.
    Thanks in advance
    Wkrgds, Levon

    welshwiggle wrote:
    So Center of Pan,
    If you were to run something like Omnipshere on an active SI track do you get anywhere near the "1 core CPU" spike I'm getting on my Late 2011 TOTR MBP?
    I still dont really get why L9 on a new MBP peforms worse than eg your PC.
    Older versions of Logic (ie: 5.5) don't see individual cores, there is one disk meter and one CPU meter. In some ways it's a more efficient system. This is running on WinXP which happens to be a very good system for audio. Consider this, XP can be installed and take up only half a gig of disk space and do 90% of what most operating systems can do today. 
    I do see single core spikes on my single processor quad core Mac Pro.  There's no way to get around a processor intensive plugin on a single track. A channel strip is tied to a single process (core). I stopped upgrading at 10.6.8 and Logic 9.1.3, because it works. I still get the occasional single core use even with multiple plugs and tracks but I can usually break the logjam by quickly starting and stopping Logic 2 or 3 times.
    I will not upgrade Mac hardware or software unless the next version of Logic is outstanding, I'm fine where I'm at for the next year or two. I enjoy recording performers more than anything else so al I really need is a good sounding, solid system.

  • [SOLVED] qemu-kvm high cpu usage when using pulseaudio alsa-plugin

    My Arch system is configured to use pulseaudio. When an application connects to the sound server it will use either a native pulseaudio driver, or the pulseaudio alsa-plugin if it using a alsa driver.
    qemu-kvm in 'extra' is not compiled with native pulseaudio support. When running guests with sound hardware support, qemu-kvm connects to the sound server using the pulseaudio alsa-plugin.
    The problem I'm seeing is high cpu usage on the Arch host even though cpu usage on the guest is low. Also, the guest is often unresponsive for a period of time when opening sound applications like the mixer or playing audio.
    My solution is to recompile qemu-kvm with native pulseaudio support. This eliminates the use of the pulseaudio alsa-plugin on the Arch host and fixes the above problems.
    An easy was to do this is run:
    yaourt -S qemu-kvm --build
    And edit the PKGBUILD changing the line:
    --audio-drv-list=alsa,sdl,oss,esd \
    To:
    --audio-drv-list=pa,alsa,sdl,oss,esd \
    Finish building and install. Don't forget to add yourself to the kvm group.
    Last edited by bytesize (2010-08-16 02:34:08)

    Problem disappeared.
    I'm not sure, but i think installing xf86-video-modesetting helped to fix this issue.
    I had an error messages in /var/log/Xorg.0.log like this:
    (EE) Failed to load module "modesetting" (module does not exist, 0)

  • [SOLVED] low speed & high CPU usage copying files between two HDD

    Both HDD are connected by SATA to the MB. One is in NTFS format (shared with windows 7) and the other one has different partitions. 
    I'm trying to copy one file (230 MB) from an ext4 partition to the NTFS HDD. The speed is about 40 kB/s and on the system monitor, I can see how one of the cores is about 100 % of usage!
    I have done these operations lot of times and never happened something like that.
    What should I have to look?
    Last edited by doblerone (2013-06-03 17:01:59)

    doblerone wrote:
    Perfect Gentleman wrote:did you install ntfs-3g ?
    Yes, it was installed.
    jrussell wrote:How have you mounted the drives? What command did you use to mount them?
    They are mounted both automatically at startup. This is my fstab:
    GNU nano 2.2.6 Fichero: /etc/fstab
    # /etc/fstab: static file system information
    # <file system> <dir> <type> <options> <dump> <pass>
    # UUID=904c8353-bb08-4e15-af53-0db8e8487b2e
    /dev/sda5 / ext4 rw,relatime,data=ordered 0 1
    # UUID=b361c968-872d-4e0b-a541-e8a046d8baf5
    /dev/sda3 /boot ext2 rw,relatime 0 2
    # UUID=da4616d1-960c-4027-a895-362c448f68f0
    /dev/sda6 /home ext4 rw,relatime,data=ordered 0 2
    # UUID=3f1764b5-242f-48d8-a8fb-5eb4223e8cda
    /dev/sda7 none swap defaults 0 0
    # UUID=EE4A513F4A5105AD
    /dev/sdb1 /media/Almacenamiento ntfs auto,user,sync,exec,dev,rw 0 0
    Why are you mounting a flash drive on your fstab? (unless its always in your PC when you boot....or you never want to remove it?)
    unmount the usb (/dev/sdb1)
    Then I think try hash out that line for the usb (/dev/sdb1) and install ntfs-3g and mount with
    mount.ntfs-3g /dev/sdb1 /mnt

  • How to limit cpu time spent on javasctipt webworkers?

    There are some pages that compute things using javascript webworkers (sample page: http://jscomputing.pl/compute.php).
    Is there any way to limit such computing? A warning window with kill button is more than I need :)
    I've searched plugins database but didnt find anything...

    There are some articles about workers on MDC:
    *https://developer.mozilla.org/En/DOM/Worker
    *https://developer.mozilla.org/En/Using_web_workers
    I don't know if it possible to terminate such a background task.
    Maybe someone at the mozillaZine Web Development/Standards Evangelism forum has ideas about if it is possible to do this.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    <br />
    See http://forums.mozillazine.org/viewforum.php?f=25<br />

  • How to set number of CPU usage at Virtual PC

    Hi all,
    After review below:
    http://support.microsoft.com/kb/824355
    I am not able to find Preference in Virtual PC manual. May i know how to set CPU usage on Virtual OS.
    Many thanks.
    Regards
    Andrew

    Hi,
    Each Virtual Machine can make use of only a single processor at a time. This is by default. if you mean that you want multiple virtual CPUs assigned then you need to look at an alternative VM system such as Hyper-V.
    Yolanda Zhu
    TechNet Community Support

  • Problem:100 % cpu usage with tcp server dll

    Hello,
     I am trying to write a dll with labwindows/cvi that allows me to create a TCP Server. This dll is integrated in labview.I created this Dll with example provides by Labwindows/cvi(rtserver.dll).
    Description of my problem: when i execute this dll in a "While Loop" in labview,the TCp server wait a connection and 100% cpu usage occurs. However when a client is connect to the server,the CPU is normaly used because the program stop when he meets the timeout of the tcpread() function. I would like to know how i could limit CPU usage  when the server is awaiting a client in the labview "While loop".
    I know I could use a DELAY() to limit Cpu usage ,but I would like to know if there are any others solutions.
    thank you.

    i dont know your exact application, but i generally use Q to transfer data to TCP loop in my prgram it helps me in two ways.
    1. it automatically restricts the iteration when ther is no data (Less CPU Usage, Less Unnecessary Trafic)
    2. Q can eliminate problems arising due to non synchronization of loop
    Tushar Jambhekar
    [email protected]
    Jambhekar Automation Solutions
    LabVIEW Consultancy, LabVIEW Training
    Rent a LabVIEW Developer, My Blog

  • CPU usage by Essbase Server

    Hello Experts,
    I have a query regarding the CPU usage by Essbase Server ? Can it be limited to certain % of the whole server by a setting ?
    Thanks in advance.
    Regards,
    Sudhir

    Hi,
    Is this not the same question as :- Query about limiting the essbase application use of CPU and RAM
    There is no essbase specific configuration to limit the cpu usage, depending on your OS you could at look at trying to limit CPU usage of a process but I am not sure how well that would work in practice.
    Another Re: "Dedicated" CPU for Essbase service that may be useful to you, not the same question but on processor usage.
    Cheers
    John
    http://john-goodwin.blogspot.com/

Maybe you are looking for

  • Problem with set parameter id

    hi all, i am using the below code to set the parameter id to project , subproject and object for the t-code in lsmw. but when it goes to lsmw it does not take these values in lsmw . can anyone please check where i am going wrong? thanks in advance. a

  • Whole Functionalities of  Fixed Asset in SAP R/3

    I just need some document o whole Funcitionalities of Fixed Assets In Sap R/i.e ECC 6.0. Best Regards, Sudhanshu Dang

  • Macbook Pro wifi and application issues, everything slow

    Hey guys, So my macbook pro has been giving me a lot of issues lately. It doesn't appear to be one particular problem and it's spread out across applications. Here's my situation: The wifi connection in my dorm room wont work all of a sudden. It's th

  • Writing to hidden file

    I created a text document in a folder and made it hidden (using file properties). This also seems to have made it read-only, but in the file properties, the read-only checkbox is not checked. Is there a different procedure for writing to a hidden fil

  • Unecpected error message, lightroom won't open

    lightroom keeps asking for a serial number and then won't open