看板 Linux 關於我們 聯絡資訊
如題 已經用renice把該程式的CPU優先權調為最高(-20) 但當編譯程式時 ($ nice -n 19 make -j 4),該程式還是會受到影響 有什麼方法可以讓一個process擁有絕對優先權嗎? 需要重新編譯核心嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.185.54 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1526823224.A.A66.html
kenduest: 怎樣觀察受到影響?是 cpu ? disk io ? or 05/20 21:42
idisnothing: process是vlc 軟解時一編程式就drop frame 05/20 21:51
kenduest: diskio 的話,看一下 ionice, 若是 cpu 就 chrt 看看 05/20 22:09
idisnothing: sudo chrt -r -p 99 $(pidof vlc) 05/20 23:05
idisnothing: sudo chrt -r -p 99 $(pidof Xorg) 05/20 23:06
idisnothing: 把vlc和Xorg都改成real-time了 但影片播放還是受影響 05/20 23:07
idisnothing: 是我指令下錯嗎? 05/20 23:07
filiaslayers: 聽起來像是想要一篇編code一邊看影片XD? 05/21 00:02
還有上網查資料,我484太貪心了QQ
kenduest: 不確定,只是用 FIFO 演算法看看... 05/21 00:07
FIFO的結果相差無幾
kenduest: 另外我不清楚是否也收到 pam 限制,你爬文查看看 05/21 00:07
kenduest: 另外若系統 cpu 已經不大能夠很有力處理多工作 05/21 00:07
kenduest: 就不要在這時候中還要編譯程式,還用 -j 4 05/21 00:08
kenduest: 其它 cpusets 這類限制 resource 的好像是其他議題 05/21 00:12
聽起來像是和cgroup差不多的東西?
Bencrie: 先弄個 preemptible kernel 再說 05/21 09:12
這蠻麻煩 束手無策再來研究
Gold740716: ulimit? 05/21 10:54
裡頭和priority比較有關的大概就real-time priority和scheduling priority 感覺功能和chrt差不多?
kenduest: 原貼用哪種 linux 版本? 05/21 17:41
idisnothing: Ubuntu 16.04 x86_64, kernel: 4.4.0-122-generic 05/21 19:51
kenduest: preemptible kernel first. 05/21 22:34
idisnothing: 看來免不了要編核心 還是用硬解比較實在 05/21 23:14
Alica: ubuntu不是本來就有編-lowlatency的kernel 05/21 23:53
試了lowlatency kernel了,情況依舊
bitlife: 編譯資料檔放SSD,影片放RAM disk或許有幫助? 05/22 09:50
這跟kernel的process scheduling比較有關,不過還是謝謝你!
bitlife: 其實我的意思是一直以為是scheduling問題,說不定是i/o 05/22 21:17
bitlife: 問題,因為頻頸不外乎cpu,memory與i/o,假設cpu及memory 05/22 21:17
bitlife: 未越級打怪,也許問題出在i/o排隊太久才讀到資料然後掉fr 05/22 21:17
bitlife: ame,特別是傳統硬碟還要按磁軌運動方向排讀寫 05/22 21:17
bitlife: 磁頭運動方向 05/22 21:18
其實我看的是電視,訊號從數位電視卡進來,不會經過HDD/SSD source code我也都丟在ramdisk裡,所以應該不太會是io的問題
bitlife: 我看推文以為是播影片檔,那是我搞錯了 05/22 21:52
是我沒說清楚 才讓你誤會 我的錯
Bencrie: DVB-T?那你是不是有開 yadif 2x,看要不要換成 bob 05/23 00:02
Bencrie: 不然就是換 mpv 播 05/23 00:12
$ uname -r 4.4.0-124-lowlatency $ vlc --version VLC media player 4.0.0-dev Otto Chriek (revision 4.0.0-dev-2926-gf683a44) $ mpv --version mpv 0.28.0-575-gd828887 Copyright c 2000-2018 mpv/MPlayer/mplayer2 projects built on Mon May 21 01:01:03 CST 2018 ffmpeg library versions: libavutil 56.18.102 libavcodec 58.19.102 libavformat 58.15.100 libswscale 5.2.100 libavfilter 7.24.100 libswresample 3.2.100 ffmpeg version: N-91132-gcadf7a7 是的,vlc 的 deinterlacer 是 yadif (2x) 我發現改成bob或yadif後,編code + 看電視不會掉禎了 但如果同時再滾動PTT網頁版的頁面就會又掉禎了 用指令sudo chrt -r -p 99把vlc和Xorg改成rt也一樣 mpv 的話,去交錯用以下三個演算法都會掉禎(編code+看電視),chrt後也一樣 yadif : mpv --vf=yadif dvb://DVB_CHAELEL yadif (2x): mpv --vf=yadif=mode=1 dvb://DVB_CHANNEL w3fdif : mpv --vf=w3fdif dvb://DVB_CHANNEL mpv我不知道怎麼用bob deinterlacer,libavfilters裡好像沒bob
abcdefghi: ionice, nocache: https://github.com/Feh/nocache 05/23 08:10
abcdefghi: 再把電視相關的app/driver buffer 設大一點 05/23 08:25
mpv的cache和平常一樣都是8~9sec左右,所以我想問題應該是不在這 https://imgur.com/Bhlkj1P ※ 編輯: idisnothing (220.132.185.53), 05/23/2018 11:11:14 剛試了一下twitch的1080p60 stream (用streamlink餵給mpv or vlc) 還是得到的一模一樣的結果 我發現mpv的frame都掉在output那邊,decoder那邊都不會掉 所以是renderer渲染的時候掉的?
Bencrie: yadif 2x 這種 deinterlace + frame doubler 很吃 CPU 05/23 12:36
Bencrie: 改用 vpdau/vaapi 用硬體 deinterlacer 05/23 12:40
Bencrie: 不然就是換一個更強的 CPU 05/23 12:40
dou0228: 換 CPU 不然就是用電視盒 不要把電視進到電腦去 05/23 15:03
硬解可解決這問題沒錯,但還是想知道要是沒硬解這問題怎辦 覺得換CPU不治本,若是os沒給ᄉ晶奰u先權,感覺resource還是多少會被share掉 電視盒會弄得線很多,而且要一邊用電腦一邊看電視也不方便,暫不考慮 這幾天會再看看問題出在哪,有進度再上來回報,謝謝各位幫忙!
Bencrie: 那就不要 -j4,-j3 留一個核心搭 taskset 啊 05/23 21:59
Bencrie: 我的印象是 Phenom II x4 945 yadif2x 1080i 就很喘了 05/23 22:01
Bencrie: 你還要玩 make -j4 高 I/O,還不知道你有沒有弄 -pipe 05/23 22:02
libavfilters(ffmpeg)如果是在自己的機器上編起來的話 yadif 2x其實跑起來還蠻輕鬆的,連我另一台X2 250都跑得動XD
dou0228: 如果靠改 Kernel 就能解 那你用 10 年前電腦也跑的動? 05/23 23:53
不太懂你的意思
Ryu3y3s: 有試過關hyper threading嗎 05/24 00:41
X4 640沒HT喔
s9209122222: 請問很爛的cpu配很小的ram是不是用vaapi硬解也是會掉 05/25 00:57
s9209122222: 幀呢 05/25 00:57
s9209122222: 我Intel Core2 Q8200+2GB RAM配上RX460開vaapi 05/25 00:59
s9209122222: 用mpv player還是狂掉幀,cpu都20~50%在跑 05/25 01:00
s9209122222: Linux上沒辦法做到像DXVA2那樣的表現嗎? 05/25 01:01
s9209122222: 而且vaapi配上好一點的chroma upscale算法就會出現畫 05/25 01:05
s9209122222: 面破碎的問題,難道用LINUX做HTPC是搖不可及的夢嗎? 05/25 01:05
s9209122222: 然後請問EDID會有影響嗎?我電視的edid貌似壞了,所 05/25 01:07
s9209122222: 以我從另一台電腦複製edid檔來用,要不然沒畫面 05/25 01:07
會不是CPU其中一個core頂到天花板了?
kdjf: 可能可以參考一下這篇,有些nice沒處理的事情(prio,group之類 05/25 07:37
謝謝你提供這個連結,我看到底下這段: Real-time features in the mainline Linux kernel Since kernel version 2.6.18, Linux is gradually becoming equipped with real-time capabilities, most of which are derived from the for‐ mer realtime-preempt patch set. Until the patches have been com‐ pletely merged into the mainline kernel, they must be installed to achieve the best real-time performance. These patches are named: patch-kernelversion-rtpatchversion and can be downloaded from http://www.kernel.org/pub/linux/kernel/projects/rt/. Without the patches and prior to their full inclusion into the main‐ line kernel, the kernel configuration offers only the three preemp‐ tion classes CONFIG_PREEMPT_NONE, CONFIG_PREEMPT_VOLUNTARY, and CON‐ FIG_PREEMPT_DESKTOP which respectively provide no, some, and consid‐ erable reduction of the worst-case scheduling latency. With the patches applied or after their full inclusion into the main‐ line kernel, the additional configuration item CONFIG_PREEMPT_RT becomes available. If this is selected, Linux is transformed into a regular real-time operating system. The FIFO and RR scheduling poli‐ cies are then used to run a thread with true real-time priority and a minimum worst-case scheduling latency. 也許打過rt-patch過後的kernel才是真正的rt-kernel?
Bencrie: @s92 問 AMD 或者換一張 NV 卡 05/25 09:58
s9209122222: 我另一台i5-4600+8G DDR3的也是RX460,用vaapi-copy 05/25 19:55
s9209122222: 可以順順跑4K HDR 59.94fps沒問題 05/25 19:55
s9209122222: 更正,i5-4460 05/25 19:57
s9209122222: 要是我舊電腦加大RAM用vaapi-copy不曉得會不會有幫助 05/25 19:58
s9209122222: ? 05/25 19:58
s9209122222: mpv開發者很排斥vaapi-glx,但他的支援度硬是比現在 05/25 20:27
s9209122222: 的vaapi好,真無言 05/25 20:27
淦,rt-kernel編好了,結果NVIDIA官方驅動不支援,欲哭無淚 =============== /var/log/nvidia-installer.log =============== -> Performing PREEMPT_RT check. ERROR: The kernel you are installing for is a PREEMPT_RT kernel! The NVIDIA driver does not support real-time kernels. If you are using a stock distribution kernel, please install a variant of this kernel that does not have the PREEMPT_RT patch set applied; if this is a custom kernel, please install a standard Linux kernel. Then try installing the NVIDIA kernel module again. ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log' for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com. ============================================================= $ uname -r 4.16.8-rt3 剛內顯HD3200開機來作測試,結果編了rt-kernel好像也沒什麼用,照樣掉幀QQ
Bencrie: vaapi-glx 支援度好正常啊,主流的 compositor 都 OpenGL 05/26 01:17
Bencrie: ram 小你要考慮會不會動到 swap。硬碟轉起來很可怕的 XD 05/26 01:20
s9209122222: 我是用SSD,然後也把vm.swapiness降到20了 05/26 07:04
s9209122222: 好奇EGL對於開發者們是好在什麼地方 05/26 07:05
※ 編輯: idisnothing (220.132.185.53), 05/26/2018 08:09:43
kdjf: 占據你要的資源的可能是其他user mode process,先試看看chrt 05/26 10:51
kdjf: 吧,這是在別的process把自己的time slice用完前就可以插入 05/26 10:52
kdjf: 真的不行才需要prempt system call 05/26 10:53
kdjf: 不過我不知道要給哪些程序更高優先度就是 05/26 10:53
kdjf: 這個程度不需要RT kernel 05/26 10:54
Bencrie: EGL 不用綁 X,不用跟 X 打交道 05/26 16:19
暫時得把這問題擱一邊了,雖然革命尚未成功,但同志我會繼續努力 謝謝各位熱心幫忙,有進展會再上來回報! ※ 編輯: idisnothing (220.132.185.53), 05/28/2018 00:31:35
s9209122222: 好消息,更新到linux4.17後vaapi-egl原本有的問題幾 05/29 23:34
s9209122222: 乎都沒了,除了HDR 60fps偶爾還是會一點點破圖 05/29 23:34
readonly: make -j1 06/02 14:56