Skip to content

Commit 9bf8981

Browse files
committed
⚡️ 优化Linux性能
1 parent dd537ba commit 9bf8981

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

app/src-tauri/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mod cmd;
22

3+
use std::path::Path;
34
use tauri::Manager;
45

56
#[tauri::command]
@@ -24,8 +25,10 @@ pub fn run() {
2425
// 相同的bug: https://github.com/tauri-apps/tauri/issues/10702
2526
#[cfg(target_os = "linux")]
2627
{
27-
std::env::set_var("__GL_THREADED_OPTIMIZATIONS", "0");
28-
std::env::set_var("__NV_DISABLE_EXPLICIT_SYNC", "1");
28+
if Path::new("/proc/driver/nvidia/gpus").exists() {
29+
std::env::set_var("__GL_THREADED_OPTIMIZATIONS", "0");
30+
std::env::set_var("__NV_DISABLE_EXPLICIT_SYNC", "1");
31+
}
2932
}
3033

3134
tauri::Builder::default()

docs/content/docs/app/misc/faq/linux.zh-CN.mdx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,54 @@
22
title: Linux 常见问题
33
icon: Computer
44
---
5+
6+
## 界面卡顿
7+
8+
通常是因为没有开启 GPU 加速或 GPU 频率过低
9+
10+
### 开启 GPU 加速
11+
12+
下列方法任选其一,或者使用其他方法,只要能修改环境变量即可
13+
14+
<Callout type="warn">
15+
如果已经定义过 `WEBKIT_DISABLE_COMPOSITING_MODE=1` 环境变量,需要先移除,因为这两个环境变量会相互冲突
16+
</Callout>
17+
18+
<Tabs items={["/etc/environment", "Shell rc 文件", "Hyprland"]}>
19+
<Tab>
20+
```sh title="/etc/environment"
21+
WEBKIT_FORCE_COMPOSITING_MODE=1
22+
```
23+
24+
</Tab>
25+
26+
<Tab>
27+
```sh title="~/.zshrc"
28+
export WEBKIT_FORCE_COMPOSITING_MODE=1
29+
```
30+
31+
</Tab>
32+
33+
<Tab>
34+
```ini title="~/.config/hypr/hyprland.conf"
35+
env = WEBKIT_FORCE_COMPOSITING_MODE, 1
36+
```
37+
</Tab>
38+
39+
</Tabs>
40+
41+
### 设置最小 GPU 频率
42+
43+
以 Intel GPU 和 TLP 调度为例,仅供参考
44+
45+
<Tabs items={["TLP"]}>
46+
<Tab>
47+
```sh title="/etc/tlp.conf"
48+
INTEL_GPU_MIN_FREQ_ON_AC=700
49+
INTEL_GPU_MIN_FREQ_ON_BAT=700
50+
INTEL_GPU_BOOST_FREQ_ON_AC=1100
51+
INTEL_GPU_BOOST_FREQ_ON_BAT=1100
52+
```
53+
</Tab>
54+
55+
</Tabs>

0 commit comments

Comments
 (0)