Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions locales/de-DE/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
},
"basePriority": {
"label": "Basispriorität",
"title": "Numerische Prozessbasispriorität, gemeldet von Windows."
"title": "Von Windows gemeldete Basispriorität des Prozesses als Prioritätsklasse. Ein Wert zwischen den Klassen, den Windows manchen Systemprozessen gibt, wird als Zahl angezeigt."
},
"workingSet": {
"label": "Arbeitssatz",
Expand Down Expand Up @@ -324,5 +324,7 @@
"fixed": "Fest",
"selectionSummary": "{count} ausgewählt",
"virtualAliases": "Virtueller Speicher virtuelle Bytes Adressreservierung"
}
},
"basePriorityBetween": "Keine Prioritätsklasse. Windows gibt manchen Systemprozessen diese Basispriorität direkt; sie liegt zwischen {below} und {above}.",
"basePriorityCustom": "Keine Prioritätsklasse. Windows gibt manchen Systemprozessen diese Basispriorität direkt."
}
6 changes: 4 additions & 2 deletions locales/en-US/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
},
"basePriority": {
"label": "Base priority",
"title": "Numeric process base priority reported by Windows."
"title": "Process base priority reported by Windows, shown as its priority class. A value between the classes, which Windows gives some system processes, shows as a number."
},
"workingSet": {
"label": "Working set",
Expand Down Expand Up @@ -324,5 +324,7 @@
"fixed": "Fixed",
"selectionSummary": "{count} selected",
"virtualAliases": "virtual memory virtual bytes address reservation"
}
},
"basePriorityBetween": "Not a priority class. Windows gives this base priority to some system processes directly; it lies between {below} and {above}.",
"basePriorityCustom": "Not a priority class. Windows gives this base priority to some system processes directly."
}
6 changes: 4 additions & 2 deletions locales/es-ES/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
},
"basePriority": {
"label": "Prioridad básica",
"title": "Valor numérico de la prioridad base del proceso indicado por Windows."
"title": "Prioridad base del proceso indicada por Windows, mostrada como su clase de prioridad. Un valor entre clases, que Windows asigna a algunos procesos del sistema, se muestra como número."
},
"workingSet": {
"label": "Conjunto de trabajo",
Expand Down Expand Up @@ -327,5 +327,7 @@
"fixed": "Fija",
"selectionSummary": "Seleccionadas: {count}",
"virtualAliases": "memoria virtual bytes virtuales reserva de direcciones"
}
},
"basePriorityBetween": "No es una clase de prioridad. Windows asigna esta prioridad base directamente a algunos procesos del sistema; está entre {below} y {above}.",
"basePriorityCustom": "No es una clase de prioridad. Windows asigna esta prioridad base directamente a algunos procesos del sistema."
}
6 changes: 4 additions & 2 deletions locales/fr-FR/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
},
"basePriority": {
"label": "Priorité de base",
"title": "Valeur numérique de la priorité de base du processus indiquée par Windows."
"title": "Priorité de base du processus indiquée par Windows, affichée comme classe de priorité. Une valeur située entre les classes, que Windows attribue à certains processus système, s’affiche sous forme de nombre."
},
"workingSet": {
"label": "Plage de travail",
Expand Down Expand Up @@ -327,5 +327,7 @@
"fixed": "Fixe",
"selectionSummary": "Sélectionnées : {count}",
"virtualAliases": "mémoire virtuelle octets virtuels réservation d’adresses"
}
},
"basePriorityBetween": "Ce n’est pas une classe de priorité. Windows attribue directement cette priorité de base à certains processus système ; elle se situe entre {below} et {above}.",
"basePriorityCustom": "Ce n’est pas une classe de priorité. Windows attribue directement cette priorité de base à certains processus système."
}
6 changes: 4 additions & 2 deletions locales/ja-JP/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
},
"basePriority": {
"label": "基本優先度",
"title": "Windows が報告するプロセスの基本優先度の数値です。"
"title": "Windows が報告するプロセスの基本優先度を優先度クラスで表示します。Windows が一部のシステム プロセスに設定する、クラスの間の値は数値で表示します。"
},
"workingSet": {
"label": "ワーキング セット",
Expand Down Expand Up @@ -321,5 +321,7 @@
"fixed": "固定",
"selectionSummary": "{count} 列を選択",
"virtualAliases": "仮想メモリ 仮想バイト アドレス予約"
}
},
"basePriorityBetween": "優先度クラスではありません。Windows が一部のシステム プロセスに直接設定する基本優先度で、{below} と {above} の間です。",
"basePriorityCustom": "優先度クラスではありません。Windows が一部のシステム プロセスに直接設定する基本優先度です。"
}
6 changes: 4 additions & 2 deletions locales/ru-RU/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
},
"basePriority": {
"label": "Базовый приоритет",
"title": "Числовое значение базового приоритета процесса, сообщаемое Windows."
"title": "Базовый приоритет процесса, сообщаемый Windows, в виде класса приоритета. Значение между классами, которое Windows задаёт некоторым системным процессам, показывается числом."
},
"workingSet": {
"label": "Рабочий набор",
Expand Down Expand Up @@ -330,5 +330,7 @@
"fixed": "Закреплено",
"selectionSummary": "Выбрано: {count}",
"virtualAliases": "виртуальная память виртуальные байты резервирование адресов"
}
},
"basePriorityBetween": "Это не класс приоритета. Windows задаёт такой базовый приоритет некоторым системным процессам напрямую; он находится между классами «{below}» и «{above}».",
"basePriorityCustom": "Это не класс приоритета. Windows задаёт такой базовый приоритет некоторым системным процессам напрямую."
}
6 changes: 4 additions & 2 deletions locales/zh-CN/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
},
"basePriority": {
"label": "基本优先级",
"title": "Windows 报告的进程基本优先级数值。"
"title": "Windows 报告的进程基本优先级,以优先级类别显示。Windows 为部分系统进程设置的介于类别之间的值以数字显示。"
},
"workingSet": {
"label": "工作集",
Expand Down Expand Up @@ -315,5 +315,7 @@
"fixed": "固定",
"selectionSummary": "已选 {count} 列",
"virtualAliases": "虚拟内存 虚拟字节 地址预留"
}
},
"basePriorityBetween": "不是优先级类别。Windows 直接为部分系统进程设置此基本优先级,介于{below}与{above}之间。",
"basePriorityCustom": "不是优先级类别。Windows 直接为部分系统进程设置此基本优先级。"
}
6 changes: 4 additions & 2 deletions locales/zh-TW/processes.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
},
"basePriority": {
"label": "基本優先順序",
"title": "Windows 回報的處理程序基本優先順序數值。"
"title": "Windows 回報的處理程序基本優先順序,以優先順序類別顯示。Windows 為部分系統處理程序設定的介於類別之間的值以數字顯示。"
},
"workingSet": {
"label": "工作集",
Expand Down Expand Up @@ -315,5 +315,7 @@
"reset": "還原預設規則",
"empty": "目前篩選條件下沒有可顯示的項目。",
"clear": "顯示全部並清除篩選"
}
},
"basePriorityBetween": "不是優先順序類別。Windows 直接為部分系統處理程序設定此基本優先順序,介於{below}與{above}之間。",
"basePriorityCustom": "不是優先順序類別。Windows 直接為部分系統處理程序設定此基本優先順序。"
}
14 changes: 1 addition & 13 deletions src-gpui/src/frontend/menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ impl Desktop {
let priorities = row
.members
.iter()
.map(|member| priority_class(member))
.map(|member| model::priority_class(member))
.collect::<HashSet<_>>();
let current = (priorities.len() == 1)
.then(|| priorities.into_iter().next().flatten())
Expand Down Expand Up @@ -1481,18 +1481,6 @@ impl Desktop {
items
}
}
/// The priority class of a base priority; other values match no class.
fn priority_class(process: &Value) -> Option<&'static str> {
Some(match process["basePriority"].as_i64()? {
4 => "idle",
6 => "belowNormal",
8 => "normal",
10 => "aboveNormal",
13 => "high",
24 => "realtime",
_ => return None,
})
}

#[cfg(test)]
mod tests {
Expand Down
56 changes: 56 additions & 0 deletions src-gpui/src/frontend/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,40 @@ pub fn disk_rate(disks: &[Value]) -> Option<f64> {
pub fn values(value: &Value) -> &[Value] {
value.as_array().map(Vec::as_slice).unwrap_or_default()
}
/// The priority class a process's base priority stands for. Windows also
/// gives some system processes base priorities between the classes (9 for
/// services.exe, 11 for smss.exe): those match no class.
pub fn priority_class(process: &Value) -> Option<&'static str> {
let base = process["basePriority"].as_i64()?;
PRIORITY_CLASSES
.iter()
.find(|(value, _)| *value == base)
.map(|(_, class)| *class)
}

/// A priority class: the base priority it gives, and its name.
pub type PriorityClass = (i64, &'static str);

/// The priority classes by the base priority each gives.
pub const PRIORITY_CLASSES: [PriorityClass; 6] = [
(4, "idle"),
(6, "belowNormal"),
(8, "normal"),
(10, "aboveNormal"),
(13, "high"),
(24, "realtime"),
];

/// The classes either side of a base priority that matches none.
pub fn priority_neighbours(base: i64) -> (Option<PriorityClass>, Option<PriorityClass>) {
let below = PRIORITY_CLASSES
.iter()
.rev()
.find(|(value, _)| *value < base);
let above = PRIORITY_CLASSES.iter().find(|(value, _)| *value > base);
(below.copied(), above.copied())
}

pub fn identity(p: &Value) -> String {
if let Some(key) = p["instanceKey"].as_str() {
return key.to_owned();
Expand Down Expand Up @@ -2898,4 +2932,26 @@ mod tests {
assert_eq!(cpu(&timeline, Some(bob)), None);
assert!(timeline.shared.is_empty());
}

#[test]
fn base_priorities_name_only_the_classes() {
let class = |base: i64| priority_class(&json!({ "basePriority": base }));
assert_eq!(class(4), Some("idle"));
assert_eq!(class(8), Some("normal"));
assert_eq!(class(13), Some("high"));
assert_eq!(class(24), Some("realtime"));
// services.exe and smss.exe sit between the classes.
assert_eq!(class(9), None);
assert_eq!(class(11), None);
assert_eq!(priority_class(&json!({})), None);
assert_eq!(
priority_neighbours(9),
(Some((8, "normal")), Some((10, "aboveNormal")))
);
assert_eq!(
priority_neighbours(11),
(Some((10, "aboveNormal")), Some((13, "high")))
);
assert_eq!(priority_neighbours(2), (None, Some((4, "idle"))));
}
}
12 changes: 1 addition & 11 deletions src-gpui/src/frontend/pages/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,17 +697,7 @@ impl Desktop {
.map(|value| label(&format!("{namespace}.{value}")))
.unwrap_or_else(missing)
};
let priority = match process["basePriority"].as_u64() {
Some(4) => Some("idle"),
Some(6) => Some("belowNormal"),
Some(8) => Some("normal"),
Some(10) => Some("aboveNormal"),
Some(13) => Some("high"),
Some(24) => Some("realtime"),
_ => None,
}
.map(|class| label(&format!("processes.priority.{class}")))
.unwrap_or_else(missing);
let priority = tables::base_priority(process).unwrap_or_else(missing);
let plain = |value: &Value| {
value
.as_u64()
Expand Down
37 changes: 37 additions & 0 deletions src-gpui/src/frontend/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,38 @@ fn process_fields(preferences: &columns::Preferences, network: bool) -> Vec<Fiel
})
.collect()
}
/// A process's base priority as its priority class, or as the number Windows
/// reports when it matches no class.
pub(in crate::frontend) fn base_priority(process: &Value) -> Option<String> {
let value = process["basePriority"].as_i64()?;
Some(match model::priority_class(process) {
Some(class) => label(&format!("processes.priority.{class}")),
None => crate::regional::number!("{value}"),
})
}

/// Why a base priority shows as a number: it lies between two classes.
pub(in crate::frontend) fn base_priority_hint(process: &Value) -> Option<String> {
if model::priority_class(process).is_some() {
return None;
}
let base = process["basePriority"].as_i64()?;
let class = |(value, class): (i64, &str)| {
format!(
"{} ({value})",
label(&format!("processes.priority.{class}"))
)
};
Some(match model::priority_neighbours(base) {
(Some(below), Some(above)) => tr!(
"processes.basePriorityBetween",
below = class(below),
above = class(above)
),
_ => label("processes.basePriorityCustom"),
})
}

fn cell(row: &Row, field: &Field) -> String {
let raw = &row.raw;
let missing = || label("format.missing");
Expand All @@ -228,6 +260,11 @@ fn cell(row: &Row, field: &Field) -> String {
.column_text(field.key)
.map(|value| columns::shown(field.key, value).into_owned())
.unwrap_or_else(missing),
// A process's priority class by name; groups mix them and show none.
CellKind::Identifier if field.key == "basePriority" => row
.metric(field.key)
.and_then(|_| base_priority(&row.members[0]))
Comment thread
digital-bombyx marked this conversation as resolved.
Resolved
.unwrap_or_else(missing),
CellKind::Identifier => row
.metric(field.key)
.map(|value| crate::regional::number!("{value:.0}"))
Expand Down
14 changes: 13 additions & 1 deletion src-gpui/src/frontend/tables/cells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ impl NativeTable {
));
}
CellKind::Pid | CellKind::Identifier => {
element = element.text_color(faint).child(value);
// A priority class name may be wider than a column set by hand.
element = element.text_color(faint).child(self.hint_text(
div().truncate().child(value),
row,
field.key,
hint,
));
}
_ => {
// Idle readings stay quiet so real load stands out.
Expand Down Expand Up @@ -265,6 +271,12 @@ impl NativeTable {
}
cached.as_ref().map(|(_, hint)| hint.clone())
}
// Keep the full class name available when a manual width truncates it;
// custom values instead explain where they sit between the classes.
("processes", "basePriority") if row.metric(field.key).is_some() => {
super::base_priority_hint(&row.members[0])
.or_else(|| super::base_priority(&row.members[0]))
}
// The busiest engine, which the figure is the share of.
("processes", "gpu") => row.gpu_usage().engine.clone().filter(|e| !e.is_empty()),
("processes", "net") => {
Expand Down
12 changes: 9 additions & 3 deletions website/src/components/replica/Columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const COLUMNS: ColumnDef[] = [
col("cpuTime", "cpu", "duration", 100, true, "CPU 时间", "累计用户态与内核态 CPU 时间;分组显示成员合计。"),
col("cpuUserTime", "cpu", "duration", 115, true, "用户 CPU 时间", "进程累计使用的用户态 CPU 时间。"),
col("cpuKernelTime", "cpu", "duration", 115, true, "内核 CPU 时间", "进程累计使用的内核态 CPU 时间。"),
col("basePriority", "cpu", "id", 100, false, "基本优先级", "Windows 报告的进程基本优先级数值。"),
col("basePriority", "cpu", "id", 100, false, "基本优先级", "Windows 报告的进程基本优先级,以优先级类别显示。Windows 为部分系统进程设置的介于类别之间的值以数字显示。"),
col("mem", "memory", "memory", 96, true, "内存", "专用工作集:进程独占的物理内存", "memory"),
col("workingSet", "memory", "memory", 110, true, "工作集", "当前驻留的物理内存,含共享页面;分组为成员工作集之和。", "memory"),
col("peakWorkingSet", "memory", "memory", 125, false, "工作集峰值", "单进程自启动以来的工作集峰值;展开应用分组查看各进程。"),
Expand Down Expand Up @@ -299,7 +299,12 @@ export function cellOf(c: ColumnDef, row: Row, ctx: CellContext): Cell {
case "cpuTime": value = total((p) => p.cpuTime); break;
case "cpuUserTime": value = total(userTime); break;
case "cpuKernelTime": value = total((p) => p.cpuTime - userTime(p)); break;
case "basePriority": value = instance((p) => priorityBase[ctx.priority.get(p.pid) ?? "正常"] ?? 8); break;
case "basePriority": {
// The class by name, as the app shows it; sorted by its base priority.
const name = instance((p) => ctx.priority.get(p.pid) ?? "正常");
if (name === null) { value = null; break; }
return { text: name, sort: priorityBase[name] ?? 8, faint: true };
Comment thread
digital-bombyx marked this conversation as resolved.
Resolved
}
case "mem": value = v.mem; break;
case "workingSet": value = v.mem * 1.38; break;
case "peakWorkingSet": value = instance((p) => p.mem * (1.46 + noise(p.pid * 5 + 2, 0) * 0.5)); break;
Expand Down Expand Up @@ -501,7 +506,8 @@ function nameNeed(row: Row, ctx: CellContext, scale: number) {
if (row.suspended) need += 8 + 14 + textWidth(translate("已暂停"), scale, 11);
return need;
}
const TEXT_COLUMNS = new Set(["name", "imageName", "path", "description", "company", "version", "architecture", "commandLine", "gpuEngine"]);
// The base priority shows a class name, as wide as a translation makes it.
const TEXT_COLUMNS = new Set(["name", "imageName", "path", "description", "company", "version", "architecture", "commandLine", "gpuEngine", "basePriority"]);
/** The narrowest and widest a text column is made, whatever its contents (widths.rs `limits`). */
const limits = (key: string): [number, number] =>
key === "name"
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/replica/Processes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ export function ProcessTable(t: TableProps) {
{others.map((c) => {
const cell = cellOf(c, row, ctx);
// Long text ends in an ellipsis; hovering shows all of it.
const long = c.format === "text" && !!cell.text;
const long = (c.format === "text" || c.key === "basePriority") && !!cell.text;
return (
<span
role="gridcell"
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/replica/i18n/catalog-map.json
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
"累计用户态与内核态 CPU 时间;分组显示成员合计。": "processes.json:column.cpuTime.title",
"进程累计使用的用户态 CPU 时间。": "processes.json:column.cpuUserTime.title",
"进程累计使用的内核态 CPU 时间。": "processes.json:column.cpuKernelTime.title",
"Windows 报告的进程基本优先级数值。": "processes.json:column.basePriority.title",
"Windows 报告的进程基本优先级,以优先级类别显示。Windows 为部分系统进程设置的介于类别之间的值以数字显示。": "processes.json:column.basePriority.title",
"当前驻留的物理内存,含共享页面;分组为成员工作集之和。": "processes.json:column.workingSet.title",
"单进程自启动以来的工作集峰值;展开应用分组查看各进程。": "processes.json:column.peakWorkingSet.title",
"进程专用的已提交内存。": "processes.json:column.commit.title",
Expand Down
Loading
Loading