How many threads my Mac use?

I installed ffmpeg and i know that it can use mulitple threads to help encode faster.


I want to know how many threads I can use on my Mac Book Pro 17" 2.2 Ghz ???

MacBook Pro, Mac OS X (10.6.8), 17 Inch Display, 2.2 GHz , ATI 1G

Posted on Aug 5, 2011 8:30 PM

Reply
8 replies

Aug 5, 2011 11:00 PM in response to albert969

Hi Albert,


That's a very specific question to which very few people are going to know the answer. I don't know if you're going to get an answer here. Does ffmpeg have a support forum or tech support number?


I don't know if there's a magic number of threads a MBP can handle, but it's quite a few. Why not close other apps you don't need to be using and increase the threads and see what happens? You can monitor threads, CPU, RAM, etc. in Activity Monitor.

Aug 5, 2011 11:06 PM in response to albert969

For maximum performance you want 1 thread per core. Assuming your system is the latest, 2011 version of the MacBook Pro, you have a quad core processor, therefore you should run 4 threads.


Note that if you're running other services at the same time as encoding you might prefer to use 3 threads in ffmpeg, leaving the other thread free for the OS and other tasks.


As a user, though, you don't get fine-grained control over the thread/core usage. At the end of the day its the OS that handles task scheduling so you cannot guarantee that using 4 cores will be the most productive. However, trying to use any more than that is overkill with no (or possibly negative) benefits.

Aug 5, 2011 11:13 PM in response to Camelot

Camelot wrote:


For maximum performance you want 1 thread per core. Assuming your system is the latest, 2011 version of the MacBook Pro, you have a quad core processor, therefore you should run 4 threads.


Note that if you're running other services at the same time as encoding you might prefer to use 3 threads in ffmpeg, leaving the other thread free for the OS and other tasks.


As a user, though, you don't get fine-grained control over the thread/core usage. At the end of the day its the OS that handles task scheduling so you cannot guarantee that using 4 cores will be the most productive. However, trying to use any more than that is overkill with no (or possibly negative) benefits.


Hi C,


If you've got time to explain a little . . . I've only got a C2D and Activity Monitor is showing well over 100 threads, so I don't understand the one thread per core . . . .


Thanks

Aug 7, 2011 10:21 PM in response to tjk

There is a difference between the number of threads in use by all applications on your machine and the number of threads in use by ffmpeg.


Yes, it's entirely possible (and likely) that you have many hundreds of threads running on your machine, but in this specific case the OP is asking about ffmpeg.


ffmpeg is a transcoding engine - it takes video and/or audio files in one format and converts them to another. Due to the nature of transcoding this is typically a linear task that can take a long time to process and single-stream tasks do not scale well over multiple processors/cores.

However, if you have multiple processors, or multi-core processes, the task can be split up into chunks and divided across the available cores/processors. THAT is what ffmpeg is giving you control over, and the number of threads you should tell fmpeg to use is directly related to the number of cores/processors on your machine.


Think of it like translating a book from one language to another - let's say Latin to English. To translate the book you have to read each sentence, understand what it's saying and translate that to the target language. You have to do it on a sentence-by-sentence basis since translating each word in turn results in nonsense, and you can't logically work on multiple sentences at a time.

As a single translator, you might be able to translate 10 pages per day, so a 100-page book will take you 10 days.

However, if you have three friends who can also translate you can divide the book into 4 chunks and give each person 25 pages each to translate. Now you'll translate the job in about 2.5 days (plus a little extra for the overhead of splitting the book and merging the chunks back together at the end).


So do not confuse ffmpeg threads with the typical thread model found in other applications. ffmpeg can easily saturate a single processor and it needs help to get the most performance out of mutli-processor/core systems.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How many threads my Mac use?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.