I just added the option to use MIT-SHM in a big application. The reason was that the Xorg process consumed 15% cpu (more than my process).
This is for just two windows, each 960×540, 30fps (using x11 locally; Linux)
It works in that I can see that the rendering is non-tearing (for which I previously had to use X11-DBE).
But the Xorg process still uses 15% cpu.
What I expected was that using XShmPutImage lets the Xorg process suffice with near 0% cpu usage.
When I disable the call to XShmPutImage then Xorg uses near 0%. This is a clue that it is not some other interaction with X11 that is causing the 15% cpu (such as event-handling).
So XShmPutImage is causing lots of work in Xorg. Can this be reduced? Can MIT-SHM be combined with X11-DBE and would that help?
Related
I have built my game in server mode on Mac OS and attached profiler to it. In profiler I can see unreasonable high cpu load.
Other scripts take a lot of cpu time. How can this be optimized?
Vsync takes a lot of time otherwise. How can it be since I have disabled VSync, built as server, run with -nographics and even removed cameras and UI?
I dont know what your game is doing in terms of calculations from custom scripts, but if its not just an empty project, then i dont see why 33ms is unreasonable. Check your servers specs maybe? Also VSync just idles for a need amount of time to reach the fixed target FPS, meaning its not actually under load, even though the profiler is showing it as a big lump of color. Think of it more as headroom - how much processing you can still do per frame and have your target FPS.
I am running on Ubuntu 18.04 on an old Dell laptop, Intel Core 2 Duo CPU and noticed that the CPU is being all used up by ordinary tasks (e.g. web browsing) that have not typically been a problem. Running
lscpu | grep 'MHz' | awk '{print }'
gives
CPU MHz: 660.0000 // This number fluctuates a little
CPU max MHz: 2200.0000
CPU min MHz: 1200.0000
The fact that the current CPU speed is way less than the advertised min seems a little concerning to me, although I don't know much about CPUs. The results are the same even when I run "stress -c 2" Is this a sign that the CPU is dying, or am I off track?
Thanks in advance.
there could be multiple problems:
There could be some background tasks, which are always running in your computer. If
you've had your pc for a lot of time, you might have installed and uninstalled many
programs/applications. Some don't complitely uninstall or leave some .exe file that
works in your background, and this can obviously use some of your's cpu power.
Or, it is likely to be the heat. If the cpu temperature is too high, the computer will
have to decrease cpu's power to stop it from overheating. To help your computer from
overheating you should either clean (in the inside) the parts where the air circulates,
close to the fans, or use some gadgets like this.
Hope this helped you! :)
I installed the cmatrix with brew on Mac(OS X 10.11.1).
The CPU usage goes to 190% when I run cmatrix and fullscreen the terminal.
It doesn't seem that you've actually asked a question, but to answer the implicit question “why is the CPU usage so high?” the first step would be for you to define “too high”.
cmatrix drives a very complex animation as fast as it can, which necessarily consumes CPU. If you profile Terminal you'll find that it spends about 100% CPU processing the output from cmatrix, and the other approximately 100% rendering the display. Since cmatrix is designed to make the terminal work, by painting the entire display every 1/30th of a second, it is unsurprising that it would keep Terminal busy most of the time. Terminal is actually showing its mettle by splitting the work onto two CPUs so that it can run at a higher frame-rate.
I have an OpenCL Windows program that does heavy number crunching and happily consumes 100% of the GPU. I'd like to be able to run it in the background while using the computer normally, but right now it causes considerable desktop lag and makes any 3d application unusable.
Is there a way to set a priority in OpenCL so that it will yield GPU power to other processes and only use spare cycles?
Unfortunately most GPU's do not support running several tasks at a time, and so there is no way to assign priority. This means that when your OpenCL kernel is running, it is the only task being executed by the GPU and that will be the case until the kernel is complete.
If you want the computer to be usable while running the kernel (normal desktop activity, browsing, videos, games) each kernel iteration would have to be very quick. So if you can reduce the time taken by each set of kernel launches (i.e. each job enqueued with clEnqueueNDRangeKernel) you might get what you're looking for. This could be achieved either through making the NDRange smaller, though it needs to be big enough to be efficient on the GPU. Something like 5120 work-items is what I've found to be the minimum on Radeon HD 5870. Or you could reduce the amount of work in each kernel.
If you can get the execution time of each enqueued job down to maybe 1/60 of a second, there's a good chance the computer will be usable. I've been able to run OpenCL programs where each enqueue takes about 1/120 of a second while gaming without noticing anything.
I develop on a laptop with a dual-core amd 1.8 GHz processor but people frequently run my programs on much weaker systems (300 MHz ARM for example).
I would like to simulate such weak environments on my laptop so I can observe how my program runs. It is an interactive application.
I looked at qemu and I know how to set up an environment but its a bit painful and I didn't see the exact incantation of switches I would need to make qemu simulate a weaker cpu.
I have virtualbox but it doesn't seem like I can virtualize fewer than 1 full host cpu.
I know about http://cpulimit.sourceforge.net/ which uses sigstop and sigcont to try to limit the cpu given to a process but I am worried this is not really an accurate portrayal of a weaker cpu.
Any ideas?
If your CPU is 1800 MHz and your target is 300 MHz, and your code is like this:
while(1) { /*...*/ }
you can rewrite it like:
long last=gettimestamp();
while(1)
{
long curr=gettimestamp();
if(curr-last>1000) // out of every second...
{
long target=curr+833; // ...waste 5/6 of it
while(gettimestamp()<target);
last=target;
}
// your original code
}
where gettimestamp() is your OS's high frequency timer.
You can choose to work with smaller values for a smoother experience, say 83ms out of every 100ms, or 8ms out of every 10ms, and so on. The lower you go though the more precision loss will ruin your math.
edit: Or how about this? Create a second process that starts the first and attaches itself as a debugger to it, then periodically pauses it and resumes it according to the algorithm above.
You may want to look at an emulator that is built for this. For example, from Microsoft you can find this tech note, http://www.nsbasic.com/ce/info/technotes/TN23.htm.
Without knowing more about the languages you are using, and platforms, it is hard to be more specific, but I would trust the emulator programs to do a good job in providing the test environment.
I've picked a PIIMMX-266 laptop somewhere, and installed a mininal Debian on it. That was a perfect solution until it has died some weeks ago. It is a Panasonic model, which has a non-standard IDE connector (it's not 40-pin, nor 44-pin), so I was unable to replace its HDD with a CF (a CF-to-IDE adapter costs near zero). Also, the price of such a machine is USD 50 / EUR 40.
(I was using it to simulate a slow ARM-based machine for our home aut. system, which is planned to able to run on even smallest-slowest Linux systems. Meanwhile, we've choosen a small and slow computer for home aut. purposes: GuruPlug. It has a cca. 1.2 GByte fast CPU.)
(I'm not familiar with QEMU, but the manual says that you can use KVM (kernel virtualization) in order to run programs at native speed; I assume that if it's an extra feature then it can be turned off, so, strange but true, it can emulate x86 on x86.)