Normal view

There are new articles available, click to refresh the page.
Today — 10 September 2025Main stream

Command tools, threads and QoS

By: hoakley
10 September 2025 at 14:30

Why is it that a fast Apple silicon Mac takes so long to tar and Gzip a large folder? Surely, with all those fast Performance cores, even GB should be compressed in the twinkling of an eye? Could it be that macOS is running the tar command on its Efficiency cores instead, eking out the power? This article explores and explains how macOS sets the priority for command tools and similar binaries.

Threads

There are two key factors at work here. The first is threading, division of the work done by a process into single flows of execution run on one CPU core at a time. Every process has its main thread, and many can also create additional threads that can be scheduled to run in parallel. While macOS can and often will move threads around its cores, a single-threaded process can only run on a single CPU core at a time.

QoS

macOS also allocates threads to cores. Although neither you nor the process control that absolutely, processes can influence it by setting a Quality of Service, QoS, for each of their threads. QoS is chosen from the standard list:

  • QoS 9 (binary 001001), named background and intended for threads performing maintenance, which don’t need to be run with any higher priority.
  • QoS 17 (binary 010001), utility, for tasks the user doesn’t track actively.
  • QoS 25 (binary 011001), userInitiated, for tasks that the user needs to complete to be able to use the app.
  • QoS 33 (binary 100001), userInteractive, for user-interactive tasks, such as handling events and the app’s interface.

There’s also a ‘default’ value between 17 and 25, an unspecified value, and you might come across others used by macOS.

If all your Mac’s CPU cores are free and idling, macOS will normally allocate threads with a QoS of 17 (utility) and higher to P cores, and those of 9 (background) and lower to E cores. That isn’t guaranteed, and there are circumstances when all threads are allocated to E cores alone, for example when a laptop’s battery is very low and it goes into energy-saving mode.

CPU History

It’s therefore tempting to assume that when a process runs very slowly, it’s being given a low QoS and is pottering along on the E cores. Although that might be correct, it’s a dangerous assumption to make. In this case, to investigate it further, I’ll take a different compressor that offers control over the QoS used for its working threads, such as my free Cormorant or the wonderful Keka.

When compressing an IPSW file of just over 18 GB, using Apple Archive’s LZFSE method in Cormorant takes 7.4 seconds at the maximum QoS of 33, but 114.7 seconds at the minimum QoS of 9. Performing exactly the same compression using aa from the command line takes about 9 seconds, so is clearly being run at high QoS. But using tar to create a tar.gzip takes forever, even longer than Cormorant running at minimum QoS.

Activity Monitor’s CPU History window is a quick and simple way to see what’s going on here, although you must be cautious when trying to interpret values such as CPU %., because those shown don’t take into account the frequency cores are run at.

This is Cormorant compressing at high QoS on all 10 of the P cores.

And this is the same compression performed at low QoS, so confined to the 4 E cores.

Compressing using aa in Terminal also makes full use of all the P cores available.

Running tar in Terminal does use the P cores, but runs in a single thread that’s shuffled between cores and takes more than 10 times as long as it would if it could be run in 10 threads.

Thus, the reason that tar is so slow isn’t because it’s given a low QoS and run on the E cores, but that it’s single-threaded (and not performant either). If you want better performance, look for a substitute that can make good use of multiple threads running in multiple P cores.

Exceptions

There are plenty of binaries that are run at low QoS, hence on the E cores, including most of those that are run in the background or scheduled using LaunchAgents and LaunchDaemons. Their property lists should specify a QoS name for their Priority key, which is often Background or Maintenance, for them to be run at a QoS of 9 or lower on the E cores alone.

There’s also the possibility that a command tool may run its own threads and assign a low QoS to them, although that should always be documented.

Summary

  • By default, command tools run in Terminal aren’t assigned low QoS and run on E cores.
  • Tools that run in single threads will invariably be slower than multi-threaded equivalents.
  • Use Activity Monitor’s CPU History window to see which core types threads are run on.

Before yesterdayMain stream

更好的问题,总是在交流之后才出现的

By: Steven
14 December 2023 at 11:40

前两天,我收到 AAAny 的 Wenbo 发来的邮件,问我是否有兴趣注册他们的 APP 体验。我一看就乐了,立马截图发给汉洋和轶轩,开玩笑地问道:「我是不是应该告诉他,我早就注册了?」

这个叫做 AAAny 的新问答社区是汉洋他们团队,从 redit 等社区平台的使用中,萌生的对于「Ask Anyone Anything」的重新思考,所做出的产品。我其实几个月前,就在一次和他俩吃饭之后就注册好了。但是一直因为忙,我担心不能及时回复别人的提问,就一直没好意思发起一场主题活动。中途有看到可达和 JT 发起的问答,很感兴趣,也想试试看,但也因为对时间的担心就止住了念头。正好借着这次 Wenbo 的邮件,跟汉洋他俩聊了一会儿后,我就趁着夜色正浓,冲动还在,就立马编辑了两段自我介绍,发起了分别以「工业设计师」和「设计类视频创作者」为主题的两场活动。

点击进入「工业设计师 SUiTHiNK AmA~

点击进入「设计类视频博主 苏志斌 AmA!

当天也是高效,一连开了三个会。中途用各种碎片时间,一一回答了 AAAny 上的提问。晚上赶回家陪筱烨过生日的路上,我一看已经回复过的内容,好家伙,累计的输出量都赶上我平时写两三篇文章了。

碎片化地高密度输出,也是可以产生一些好内容的。

在使用了一天后,当晚,我和汉洋、轶轩聊了聊感受。汉洋问我感觉 AAAny 和知乎之间有什么区别?我打了一个比方:

知乎的问答是一种广场上的广播。一个问题对应一个完整的回答,虽然我可以不断修改回答,但是你修改后的内容很难再被之前看过的人再次看到。评论区就是一些人在外围窃窃私语,它们和主回答之间很难形成交流互动。它是有层级的、单向的信息传播。

但是 AAAny 给我的感觉,是老城区的街头沙龙。任何对话都是水平方向的,没有任何层级关系,就和大家在街头聊天一样。你看到一个感兴趣的话题,就可以直接加入;别人对你们正在谈论的感兴趣,也可以随时参与进来。它不是广播的形式,是集会和交流的空间。

有意思的事情在于,我们往往需要遇到好问题,才能写出一个好的回答。

然而,好的问题通常并不是我们提出来的第一个问题。你会在持续的提问和持续的回复之间渐渐发现,那些更本质和更有趣的问题。这是知乎解决不了的。好的问题如果都由运营和编辑来提出,那么知乎的运营压力会爆炸;如果都由用户提出,那么一定伴随着海量毫无意义的垃圾问题,这对真正的好问题是一种掩盖。

因此,持续的对话和前后文关系的保留,就很重要。同时也得确保,来自对话后段出现的好问题/好回答,能够被之前关心这个话题的人看到,也能被后来的观众发现。

运营这样的社区,需要真正会采访的记者。

点击进入「工业设计师 SUiTHiNK AmA~

点击进入「设计类视频博主 苏志斌 AmA!

❌
❌