CN

Performance Considerations in Operating System Design

Word count: 3kReading time: 18 min
2023/08/21
loading

This article was originally written by Yingyun for my Knowledge Planet. Since the Planet has closed, I am publishing this series on OS performance design here.

Yingyun is a veteran performance optimization expert with deep insights into system-level tuning, having worked at several major smartphone manufacturers. He is currently active in our community. If you have any questions or feedback, feel free to join our WeChat group.

1. The Genesis

This starts a new series exploring the various considerations in OS architectural design. In reality, these principles apply to the design of any large-scale software.

My knowledge and experience have limits, and these views are subjective. There will be gaps. I would like to hear other views and see what I have missed.

Technical review: 2026-10-14. This article retains Yingyun’s 2023 views on architectural trade-offs and developer ecosystems. Technical sections clarify kernels, memory reclamation, and background execution with version-specific updates. Platform preferences and forecasts are historical opinions, not comparative measurements of current releases.

From an OS perspective, I believe the core differences between Android and iOS manifest in four areas:

  1. IPC Mechanisms between applications and core services.
  2. Platform Development Environment: programming languages, IDEs, and developer ecosystems.
  3. Application Lifecycle Management: mechanisms and strategies.
  4. Runtime Organization of the kernel and core services.

Why did they make such different strategic decisions? It comes down to the constraints and goals they faced when making those decisions. A software architecture is a collection of decisions made to be the most “correct” for the present and foreseeable future. There is no absolute right or wrong—only choices made under different pressures. If you swapped the contexts of two equally skilled architects, they would likely end up with very similar designs. Architecture is an engineering craft; it follows predictable patterns.

The challenge lies in accurately understanding the organization’s environment and anticipating which factors—testability, release efficiency, security, reliability, performance, or scalability—must be prioritized. An experienced architect knows when to be rigid and when to compromise. Because of the law of diminishing marginal utility, these trade-offs continue throughout the software’s entire lifecycle.

Key takeaways:

  1. Software architecture design varies across different projects based on phase and constraints.
  2. Design decisions are fluid and happen continuously throughout the product lifecycle.

Interestingly, optimization goals often conflict. For example, increasing developer efficiency often comes at the cost of runtime performance. What were the priorities for the original designers of Android and iOS? To answer that, we must first define the relationship between the OS, the application, and the kernel.

2. Mechanism vs. Strategy

The OS and applications form a software stack above the hardware. Kernel code normally runs in a privileged CPU mode for tasks such as scheduling, memory management, and interrupt handling. Many system services run in user space with particular permissions; the entire OS does not run in kernel mode. Apps access these capabilities through system calls, IPC, and framework APIs.

From a user experience (UX) perspective, the hardware, OS, and app are a single entity. If they fail to collaborate, the device feels broken. All three have an obligation to cooperate to satisfy the consumer.

Most modern OSs consist of a Kernel and System Services:

  • macOS/iOS use the XNU kernel, which combines Mach, BSD components, and IOKit. XNU is part of the Darwin operating-system foundation; Darwin is not a kernel formed by placing XNU beside Mach. User-space daemons and frameworks provide further services. See Apple’s XNU overview.
  • Android uses the Linux kernel. SurfaceFlinger is a native system-service process; system_server hosts many Java framework services and also uses native components. Neither is the kernel itself.

While many OSs use similar foundations, the way they are deployed matters. Running an OS is not the same as running it well.

The Art of Unix Programming describes separating policy from mechanism and interfaces from engines. Mechanism provides a capability; policy decides how to use it.

  • Mechanism: Provides the capability (the “How”).
  • Strategy: Decides how to use that capability (the “What”).

The boundary depends on the level of discussion; an entire scheduler or filesystem contains both mechanisms and policies. For example, the kernel provides scheduling and frequency-control facilities, while policy uses workload and foreground/background information to choose resource allocations. A governor selects performance targets and a driver performs supported transitions. DVFS describes voltage/frequency scaling; predicting demand and choosing targets are policy decisions. See Linux CPUFreq’s governor/driver separation.

These decisions can combine application hints, system state, and hardware constraints. A policy that works for a server may not suit a phone or watch, even when both use Linux.

Memory compression is used by many systems, but it is not a requirement for every modern OS. Apple’s WWDC 2018 memory discussion describes the page-based compressor introduced in iOS 7; this does not mean compressing an entire process into one object. Android commonly uses Linux zRAM as a compressed in-memory swap device. Compressed pages still occupy RAM, and compression/decompression costs CPU time. Policies and any additional backing storage depend on the device.

Mechanisms might be similar across OSs, but strategies vary wildly. This depends on the designer’s understanding of the target service. The original desktop analogy concerns background-execution freedom; it does not mean Android was originally a desktop OS. Whether a vendor policy better suits a mobile device depends on its version and workload. Kernel, IPC, runtime, and framework differences also matter; policy is not the only source of performance differences.

One policy can create a problem that needs another policy to address it. Eventually, several policies may depend on one another to work well. Copying just one visible feature from another OS can miss those dependencies and make things worse. That is the kind of “negative optimization” I worry about.

3. Perspective Decisions

Apple’s operating systems share parts of their foundations but differ in background-execution, interaction, and resource policies. Both iOS and macOS support multitasking. iOS places stricter limits on ordinary third-party apps in the background; it does not lack “real” multitasking. The comparison here concerns product policies.

AOSP is Android’s open-source foundation; shipped Android products may also include vendor components and separately licensed services. Manufacturers take AOSP, add hardware-specific code and their own services. Since manufacturers have different business models and user bases, they modify AOSP differently. The market ultimately judges which modification is superior.

So if a boss tells you, “Making a phone is easy—just combine open-source Android with a vendor platform,” my advice is to keep your distance. You could waste years working under that assumption.

AOSP already contains resource and lifecycle policies, including JobScheduler, Doze/App Standby from Android 6.0, lmkd, and the cached apps freezer from Android 11. These policies are not all implemented in GMS. GMS is a separately licensed collection of apps and cloud services outside AOSP. Vendors can further adapt the platform; comparisons need specific devices, versions, and workloads.

The Origin Story

The verifiable timeline is that Apple announced third-party Web apps in June 2007, then released a native iPhone SDK beta and introduced the App Store in March 2008. The SDK included Xcode, Interface Builder, and Instruments. The original article discussed motives through the Jobs biographies, but it supplied no performance evidence that XNU overhead made third-party applications impossible. That causal claim should not be treated as a technical finding.

Contrast this with Android. Andy Rubin’s goal was a truly open system to balance the interests of developers, manufacturers, and carriers. This required using off-the-shelf components to deploy quickly. There was no time for the same level of polishing because they were in a race for survival.

Java offered a mature ecosystem and portability; its exact market rank depends on the measure used. Early Android used Dalvik, while ART became the default in Android 5.0 (API 21). They were not one VM designed together in 2007. Chet Haase’s Androids: The Team That Built the Android Operating System covers the early team. Google’s December 2007 SDK update already describes an Eclipse plugin; public SDK tooling was not limited to command-line tools.

The Power of the IDE

I consider Apple’s developer tools one part of its ecosystem advantage. This is a 2023 assessment, not a current feature or performance ranking of Xcode and Android Studio. LLVM also needs distinct attribution: it originated in research at the University of Illinois, with Apple later contributing; it should not be grouped with Swift and SwiftUI as an entirely Apple-originated project. See the University of Illinois history.

My view when writing in 2023 was that the early Eclipse tools had been adequate, but comparison made their shortcomings harder to ignore. Android Studio was a big improvement, helped by IntelliJ. I still preferred Xcode for application development and performance debugging: finding slow code felt easier, and the process was more pleasant. That is my experience of those tools at the time.

Designing an OS is a means to an end (profit). To achieve that, you must help developers write good code. Many OSs provide the capability but leave the quality to the developer. Apple’s approach is: “I’ll give you limits, but I’ll also give you the solution to work within them.”

4. Strategy: Overload Protection

Phones run on batteries and mostly rely on passive cooling, with gaming phones and attachable fans as exceptions. Actual heat depends on workload, voltage, frequency, process technology, and power management, so transistor count alone does not tell us how hot a phone will get. The design problem is balancing performance, battery life, and temperature.

More runnable threads can compete for CPU time, and frequent wake-ups can use more energy. Thread count, CPU time, and visible delay are different measures. Desktops and servers have resource controls too; mobile devices place more weight on battery life and heat.

Java OutOfMemoryError, lmkd under system memory pressure, and the Linux kernel OOM killer operate at different levels. A managed-heap allocation failure can throw OOME; an unhandled error can crash the app. This is not simply a system kill when the heap crosses a threshold. lmkd instead considers memory pressure and process importance. Android 10 supports PSI-based detection, and Android 11 revised the reclaim policy.

CPU accounting is not divided by Java versus native code. Android 13 AppProfiler accumulates process user and kernel CPU time; ActivityManagerService applies process-state, observation-window, and threshold checks when handling excessive CPU use. Accounting scope and termination policy are separate; native threads are not inherently excluded.

iOS diagnostics also need to be separated by mechanism rather than described as a list of guaranteed kills:

  • EXC_RESOURCE can concern CPU, wake-ups, memory, or disk writes. NON-FATAL CONDITION means the report did not terminate the process on that occasion.
  • Jetsam reports describe process reclamation under memory and related pressure. vnode-limit concerns system-wide vnode exhaustion; fc-thrashing concerns file-cache thrashing. A background app selected for reclamation need not have caused the pressure.
  • A watchdog termination concerns time limits for responsiveness or lifecycle operations, not the same threshold as a resource exception.
  • Background tasks have API-specific completion and expiration requirements. Thermal protection can also apply, but a warmer device does not mean every app is immediately terminated.

Use the actual diagnostic report, hardware, and OS version to identify a termination. Example limits are not universal quotas across iOS devices and releases.

Vendors add resource controls to protect the user experience. But if the rules are undocumented and developers cannot find out why their app was terminated, how are they supposed to fix it? That is the part I object to.

Android 11 (API 30) added ApplicationExitInfo for historical process-exit information. Coverage varies: not every device reports REASON_LOW_MEMORY, and a trace is not always available. Vendor details can still be incomplete, but it is inaccurate to say developers have no exit information at all.

When developers respond with more tricks to keep their apps alive, cooperation turns into an arms race. Users pay for it. What I would like to see is clear documentation of resource limits, accessible diagnostic information when those limits are enforced, and tools that help developers fix the problem locally. Vendors should set quality requirements and require fixes, with removal from the store as a last step if those requirements are not met.

Manufacturers and developers should be partners. Many of the tools and system capabilities are in the manufacturer’s hands. Blaming developers for everything is a poor starting point.

5. Strategy: Lifecycle Management

Device categories use different lifecycle policies. Desktop apps generally have more scope for continuous execution, but users, crashes, memory pressure, shutdown, and administrative policies can end them. Desktops, servers, and laptops also face power, thermal, and resource limits; an app does not wholly control its lifetime.

Smartwatches make the constraints particularly obvious. Nobody wants a watch that heats their wrist and cannot last a day. Shared system services can do work that would otherwise require many separate apps to remain active.

iOS normally suspends ordinary execution after an app moves to the background. A suspended process does not execute code, but suspension is not termination. The original “five seconds” refers to the applicationDidEnterBackground return deadline, not a universal allowance for every background API. Specific modes and task grants have their own rules.

The original vendor comparison reflects a 2023 observation, not evidence about the following two or three years. AOSP does support freezing: the cached apps freezer has existed since Android 11 (API 30), using a kernel cgroup freezer to stop eligible cached processes while retaining their memory. Android 14 revised related cached-process and broadcast behavior. Enablement, exemptions, and timing depend on the OS, kernel, and device configuration. A process doing supported background work or hosting a foreground service is not necessarily eligible for cached-process freezing.

If an app is suspended in the background, how can it do the work that still needs doing? iOS offers several mechanisms, not one BackgroundTask permission:

  • UIKit beginBackgroundTask requests limited finishing time for important work already started in the foreground. End it promptly and handle expiration; it is not a periodic scheduler.
  • BGAppRefreshTask, available from iOS 13, supports short refresh work scheduled by the system, with up to about 30 seconds of runtime.
  • BGProcessingTask, also from iOS 13, supports longer processing. It can run for minutes but can be interrupted; it has no universal fixed 30-second allowance.
  • iOS/iPadOS 26 adds BGContinuedProcessingTask for user-visible work that starts in the foreground and continues in the background. It must report progress; the user can cancel it, and resource constraints can end it.

See background strategy selection, BGProcessingTask, and BGContinuedProcessingTask. The system chooses scheduling and budgets. There is no fixed daily count for every app or guaranteed periodic interval. Handle expiration, preserve progress, and report completion.

Background work also includes playing music, tracking location, and transferring files. How are those handled? They have distinct capabilities, permissions, and APIs. App Store review governs distribution; on-device OS mechanisms decide execution, suspension, and reclamation. The store is not the runtime scheduler. Memory pressure can terminate suspended processes, but reclamation also includes discarding caches and compressing memory rather than only killing processes.

What if the process has been terminated altogether—how does it run tasks or receive messages then? After system termination, eligible tasks may launch an app in the background, but this is not unconditional. User force-quit also differs from system reclamation; see Apple’s background execution limits. Distinguish system-displayed visible notifications, silent background-update notifications, and VoIP pushes for real incoming calls.

Background notification delivery and wake-up are not guaranteed and can be throttled. Background work is not limited to a notification tap or VoIP. PushKit VoIP notifications serve incoming calls; apps built with the iOS 13 SDK or later must follow the documented CallKit integration, not use them as a general keep-alive channel.

Android background scheduling and push delivery are separate. JobScheduler has provided platform job scheduling since API 21, and WorkManager does not require Google Play services. Neither is simply a GMS feature or permission for permanent process residency.

The standard FCM Android client requires the corresponding Google-services environment. Vendors also offer channels such as HUAWEI Push Kit. Device coverage, delivery, and execution rules differ. Lack of GMS does not technically require permanent app processes, and adding RAM is not the only possible response. My argument remains that vendors and app developers need to build the ecosystem together, instead of each solving only their own part of the problem.

6. Designing for the Future

Specialized accelerators can improve efficiency for particular workloads, as seen in GPUs, media codecs, and machine-learning engines. They do not imply that general-purpose CPUs have stopped improving or that every program benefits equally. DSA (Domain-Specific Architecture) tailors hardware and software interfaces to a domain. The idea that DSA would dominate the next decade’s gains is retained as the author’s 2023 forecast, not a verified prediction.

The 2020 M1 combines CPU, GPU, Neural Engine, and media encode/decode engines. Accelerator benefits depend on the task, format, and software path. A blanket claim that it outperforms Intel chips ignores generations, power limits, and workloads. This article provides no controlled benchmark; the example illustrates architectural specialization rather than a platform ranking.

Improving performance still requires understanding the work, then looking at algorithms, compilers, hardware, and the OS when application-level changes stop being enough. Failures teach you where a design needs support. By an “optimization matrix,” I mean the related pieces that have to work together: the OS, developer tools, cloud services, and the decisions connecting them.

The more I learn, the more work I can see to do. I want to stay aware of what I do not know. That is also why I value Munger’s advice to learn across disciplines. I have not reached the breadth of understanding I am describing; studying outside my specialty and writing down what I learn are ways to work toward it.


About Me && Blog

  1. About the author
  2. Blog content navigation
  3. Android performance resources
CATALOG
  1. 1. 1. The Genesis
  2. 2. 2. Mechanism vs. Strategy
  3. 3. 3. Perspective Decisions
    1. 3.0.1. The Origin Story
    2. 3.0.2. The Power of the IDE
  • 4. 4. Strategy: Overload Protection
  • 5. 5. Strategy: Lifecycle Management
  • 6. 6. Designing for the Future
  • 7. About Me && Blog