Skip to content

Commit

Permalink
system: add option to only use pcores
Browse files Browse the repository at this point in the history
Resolves #2557
  • Loading branch information
osy committed Jul 10, 2021
1 parent c33f1ee commit 20846c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Managers/UTMQemuSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ - (CPUCount)emulatedCpuCount {
return singleCpu;
}
#if defined(__aarch64__)
CPUCount hostPcoreCount = {
.cpus = sysctl_read("hw.perflevel0.physicalcpu"),
.threads = sysctl_read("hw.perflevel0.logicalcpu"),
};
// in ARM we can only emulate other weak architectures
if ([arch isEqualToString:@"alpha"] ||
[arch isEqualToString:@"arm"] ||
Expand All @@ -141,7 +145,11 @@ - (CPUCount)emulatedCpuCount {
[arch hasPrefix:@"ppc"] ||
[arch hasPrefix:@"riscv"] ||
[arch hasPrefix:@"xtensa"]) {
return hostCount;
if (self.useOnlyPcores && hostPcoreCount.cpus > 0) {
return hostPcoreCount;
} else {
return hostCount;
}
} else {
return singleCpu;
}
Expand Down Expand Up @@ -503,6 +511,11 @@ - (BOOL)useHypervisor {
#endif
}

- (BOOL)useOnlyPcores {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
return [defaults boolForKey:@"UseOnlyPcores"];
}

- (BOOL)hasCustomBios {
for (NSUInteger i = 0; i < self.configuration.countDrives; i++) {
UTMDiskImageType type = [self.configuration driveImageTypeForIndex:i];
Expand Down
5 changes: 5 additions & 0 deletions Platform/macOS/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct SettingsView: View {
@AppStorage("NoHypervisor") var isNoHypervisor = false
@AppStorage("CtrlRightClick") var isCtrlRightClick = false
@AppStorage("NoUsbPrompt") var isNoUsbPrompt = false
@AppStorage("UseOnlyPcores") var isUseOnlyPcores = false

var body: some View {
Form {
Expand All @@ -38,6 +39,9 @@ struct SettingsView: View {
Toggle(isOn: $isNoHypervisor, label: {
Text("Force slower emulation even when hypervisor is available")
})
Toggle(isOn: $isUseOnlyPcores, label: {
Text("Use only performance cores by default")
})
}
Section(header: Text("Input")) {
Toggle(isOn: $isCtrlRightClick, label: {
Expand All @@ -60,6 +64,7 @@ extension UserDefaults {
@objc dynamic var NoHypervisor: Bool { false }
@objc dynamic var CtrlRightClick: Bool { false }
@objc dynamic var NoUsbPrompt: Bool { false }
@objc dynamic var UseOnlyPcores: Bool { false }
}

@available(macOS 11, *)
Expand Down

0 comments on commit 20846c5

Please sign in to comment.