6

Creating a kiosk application for the Mac and am testing performance and CPU usage. The activity monitor shows a total of roughly 90 to 150% CPU usage for the always up, kiosk processes.

My first confusion is how CPU usage can be over 100% but I understand it is related to the number of cores.

So my question is, is 150% total CPU usage acceptable for a kiosk based mac with constantly running 24-7 applications? Or is that too high?

addendum> the application is processing video constantly, the only 'interaction' is the video feed coming from a webcam.

  • 7
    Is your Kiosk app doing stuff that can justify 150% of CPU? – CousinCocaine Oct 11 '15 at 16:54
6

Zero is Ideal

Ideally, your kiosk application should use 0% CPU when not actively being used. It is unlikely you will achieve this without considerable effort but even a target of 5 – 10% use is good.

At 150% constant CPU use, the application would likely be considered faulty by Apple's Mac App Store reviewers – and by many customers.

Hints: Offload to the Right Framework

If your kiosk application is animating or showing moving content such as adverts or movies, do as much as you can with AVFoundation/QuickTime. This will typically offload the processing to the GPU and allow the CPU to idle.

For other animations be sure to adopt CoreGraphics and CoreAnimation. They will dramatically improve your application's energy impact.

Energy Efficiency Guide for Mac Apps

Study Apple's Energy Efficiency Guide for Mac Apps. The introduction sets out Apple's intentions:

Your Obligation as a Developer

Even small inefficiencies in apps add up across the system, significantly affecting battery life, performance, responsiveness, and temperature. As an app developer, you have an obligation to make sure your app runs as efficiently as possible. Use recommended APIs so the system can make smart decisions about how best to manage your app and the resources it uses. Whenever possible, avoid unnecessary updates to the user interface and I/O. Power-intensive operations should be under the user’s control. If a user initiates a large iMovie render, Automator batch job, Compressor conversion, or Xcode compile, for example, the user should not be surprised if the activity consumes power. Strive to make your app absolutely idle when it is not responding to user input.

Use the developer tools to profile your application's energy impact and ask away on Stack Overflow for ways to reduce CPU load. Good luck!

  • 2
    Your "zero is ideal" statement reminds me of the old saw that I think is pure Yogi Berra "In theory, there is no difference between theory and practice. In practice, there is." You make good points for being a good citizen in a multi user or multi app environment, but kiosk use is the epitome of a zero sum game. Why spend more to reduce CPU or buy additional hardware when you have ample room for degradation. i7 has 4 cores, 8 threads and one process is taking 1.5 of the 8 threads that are available. Seems like a non-issue to me. – bmike Oct 11 '15 at 18:38
  • 1
    150% CPU would concern me regardless of being a single use device. A single 3.6Ghz i7 core is powerful and I wonder what is consuming all those cycles. But you are right, if the budget allows, the heat created is not a problem, and the user experience is great, then almost any CPU use could be ignored. – Graham Miln Oct 11 '15 at 19:19
  • 1
    Indeed - it's like someone saying "I'm not going to enjoy this movie since the projector uses 1500 watts and there's only one person watching the movie right now." Everything is a trade off in engineering - yes, make efficient code when you can, but investing 10k dollars to re-do something that's running in animations in HyperCard for a building that's open three evenings a week and all day weekends would be a poor use of funds for a non-profit. It's a bit entertaining to see how everyone sees this question through their own experiences - and I am part of that "seeing" it my way. – bmike Oct 11 '15 at 19:52
  • 3
    Just a warning: ask away on Stack Overflow for ways to reduce CPU load That'd be off-topic without a specific code example, as 'Too Broad'. – AStopher Oct 11 '15 at 20:44
  • 1
    "At 150% constant CPU use, the application would likely be considered faulty by Apple's Mac App Store reviewers – and by many customers." - if this is for a kiosk, then why would the app be on the app store, and why would customers be able to see the CPU usage? – immibis Oct 11 '15 at 22:36
1

150% of the total CPU would, of course, not only be totally unacceptable - but physically impossible.
I know most sportsmen seem to think that they can give at least 110% every time they are interviewed, but no-one pointed out the simple facts to them, I guess ;-)

Activity Monitor shows individual applications' CPU usage per core [including virtual cores], so 150% is actually (for an i7, with 4 cores + hyperthreading) 150 / 8 = 18.75% of the total machine capability.

The System + User total underneath the individual figures is a more accurate representation of the overall machine usage & a quick tot-up of the figures gives you a rough idea that this is in fact the true state of things.

enter image description here

Taking this as an example, the visible percentages add up to about 120, yet the System + User figure is only 5.3%
I have 24 virtual cores [2 x 6-core CPUs + hyperthreading] so 120 / 24 = 5 [close enough to account for the processes further down the list]

At 18.75% of the total machine's capacity, I don't see it being worth the effort to optimise - unless another process needs any significant portion of the remaining capability.

0

Unless you have a problem, don't prematurely optimize would be my advice. The hardware will run at 100% usage (or 800% of one single thread in your hardware's case) with no ill effect and unless you have blocking effects - your animations and kiosk functions might not even degrade when the CPU is totally busy 24/7.

If there are low hanging fruit to reduce CPU, go for it, but the i7 has 4 physical cores and calculates CPU loading against 8 virtual cores. Your hardware goes to 800% ideally and you are only at 150% presently? Seems like you specifications for hardware are more than overkill for a single use kiosk situation. If you have chosen a technology stack and are happy with the contents of the kiosk in terms of animation, ability to perform the task you are "hiring" it to do - I wouldn't worry about some externally imposed "best practice" even if it's Apple's guidelines to be an efficient coder (which are EXCELLENT by the way).

On any system, you might want to plan to not exceed 80% utilization if you cannot benchmark, measure, react and correct burst usages. This is a guideline, and of course when you can do better, you should.

I'll assume you actually have remote access tools in place to push updates and can measure the CPU over time and react, but kiosk interactivity seems low on the "we lose money" when the system lags.

  • How long does a user interact with the kiosk?
  • Is money being made or lost and at what rate is that estimated?
  • What happens to the system when it becomes CPU bound (due to background processes or change in the app)?

Any "best practice" really is a starting point for you to evaluate things. There's no reason to not leave a computer running 100% utilization if the main thread isn't blocked and the system as a whole degrades gracefully.

  • 3
    150% constantly is absolute insanity for any app that isn't doing anything, especially a (consumer-facing, I assume) kiosk. There's a non-trivial power usage difference between idle and 150% usage - over a couple of machines, running 24/7, this can turn into a decent amount of money very very quickly. – Undo Oct 11 '15 at 19:18
  • 1
    @Undo Are you assuming that the app is doing nothing or do you know the app is doing nothing? The OP states that the CPU usage is between 90 and 150%. I'm not ready to assume negligent software design/selection from one data point. Also, your power usage complaint seems specious without knowing the larger picture. Are you advocating to shut down all computers that use energy? Again, your assumption that the code is gratuitously using CPU and harping on electricity costs comes across as a fallacy of relative privation. – bmike Oct 11 '15 at 19:43
  • 1
    Of course not - I'm not advocating it as an environmentalist or anything like that, but the fact is that if you're running these kiosks, and using that much CPU, without a good reason ('kiosk' in my mind is something consumer-facing, doing minimal work) can get expensive if you're not getting any value out of it. I'm not saying that we need to drop everything and focus on energy costs, but it is a factor. I'd like to see clarification from the OP about what he's actually doing, but if it's just displaying information... something's wrong here. – Undo Oct 11 '15 at 20:50
  • 1
    @Undo So why are you commenting on my answer if the OP needs clarification? 150/800 is 18.5 % duty cycle - you have an odd "insanity" threshold to characterize such a lightly loaded system. – bmike Oct 11 '15 at 21:20
  • 1
    The application is processing video, the only interaction is the video feed coming from a webcam – Bachalo Oct 12 '15 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .