Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Linuxのプロセススケジューラのしくみ その2 タイムスライスの計算方法
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Satoru Takeuchi
PRO
September 27, 2020
Technology
1.5k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Linuxのプロセススケジューラのしくみ その2 タイムスライスの計算方法
以下動画のテキストです
https://youtu.be/s7OEjcGHAXQ
Satoru Takeuchi
PRO
September 27, 2020
More Decks by Satoru Takeuchi
See All by Satoru Takeuchi
119-多機能ファイルシステムBtrfs_のコピー.pdf
sat
PRO
1
79
Linuxカーネルの インタフェースは変わりうる?
sat
PRO
1
110
あなたの知らないバージョン命名規則
sat
PRO
3
920
Rook: Intro and Deep Dive with Ceph
sat
PRO
1
74
Machine Check Exception
sat
PRO
2
71
バイナリダンプの模様を読む
sat
PRO
0
110
cpコマンドはディスク上でデータを コピーしないことがある
sat
PRO
3
110
114-ファイルのshallow_copy.pdf
sat
PRO
2
63
113-Btrfsのスナップショット.pdf
sat
PRO
0
47
Other Decks in Technology
See All in Technology
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
190
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
2
310
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
280
Temporal 最高!でも改めて「日付」について調べたら人類の負債すぎる件
riyaamemiya
0
190
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
840
会社紹介資料 / Sansan Company Profile
sansan33
PRO
31
430k
AI導入は済んだ。次は統制を作り替える番だ_AI×開発組織 Summit 2026
techtekt
PRO
0
380
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
200
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.3k
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
110
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
870
Accessibility Awareness
sabderemane
1
250
Typedesign – Prime Four
hannesfritz
42
3.2k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
830
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
730
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
560
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
The Invisible Side of Design
smashingmag
301
52k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Transcript
Linuxのプロセススケジューラのしくみ その2: タイムスライスの計算方法 Aug 30th, 2020 Satoru Takeuchi Twitter: satoru_takeuchi,
EnSatoru 1
おさらい • その17 Linuxのプロセススケジューラの仕組み その1 時分割によるスケジューリング ◦ 実行可能プロセス数 nが増えるとタイムスライスが短くなったような …?
2 0 1 0 1 2 0 1 2 3
• タイムスライス=レイテンシターゲット/実行可能プロセス数n ◦ レイテンシターゲットとして決めた時間に一回 CPU時間を得られる タイムスライスの計算方法 3 n=2 n=3 n=4
時間 t0 t1 t0 t1 t0 t1 t2 t0 t1 t2 t0 t1 t2 t3 t0 t1 t2 t3 レイテンシターゲット レイテンシターゲット
レイテンシターゲットの値 • sysctlパラメタによって読み書き可能 ◦ kernel/sched_latency_ns [ナノ秒] • パラメタチューニングの基準 ◦ 応答性能重視(主にデスクトップ環境
): 値を小さくする ◦ スループット重視(主にサーバ環境): 値を大きくする • CPU数が変わると変化する ◦ レイテンシターゲット =1CPUのときのレイテンシターゲット ×(1+log2(ncpus) ▪ CPU数が多いとサーバ用途が多いだろうという推測 ▪ CPU数が多いとプロセス起床時に他の CPU上ですぐ動ける可能性が高い 4
タイムスライスの最低保証値 • 例: レイテンシターゲットが10msでnproc=1000 ◦ 各タスクのタイムスライスはたったの 10us? • タイムスライスの最低保証値がある ◦
目的: コンテキストスイッチのコストを増やしすぎないようにするため ◦ Sysctlのkernel.sched_min_granularity_ns 5
nice値の意味 • niceの変化によってタイムスライスの比率が変わる ◦ nice値が小さい(高優先度): 比率が上がる ◦ nice値が大きい(低優先度): 比率が下がる •
レイテンシターゲットは変わらない 6 p0 p1 p0 p1 p0 p1 時間 p0 p1 p0のnice値 > p1のnice値 p0のnice値 == p1のnice値 p0のnice値 < p1のnice値 p0 p1 p0 p1 レイテンシターゲット レイテンシターゲット
実験 • 目的 ◦ タイムスライスにnice値が与える影響を確認 • 実験プログラムnice.cの概要 1. 1つのCPU上で無限ループするプロセス p0とp1を同時に100ミリ秒間動かす
▪ 第一引数としてp1のnice値を与える: -10 or 0(デフォルト値) or 10 2. 2つのプロセスはCPUを1ミリ秒使うごとに次の情報を記録する ▪ プロセスの番号 ▪ プロセス開始時からの経過時間を記録 3. 100ミリ秒経過後に2つのプロセスの記録を出力 7
結果 8 p0 p1 p0 p1 p0 p1
まとめ • タイムスライスは実行可能プロセス数が増えるほど短くなる ◦ レイテンシターゲットに定めた期間に一回 CPU時間を得られる ◦ コンテキストスイッチコストが高くなりすぎないように最低保証値がある • CPU数が増えるとレイテンシターゲットの値が増える
• nice値による優先度の高低によってタイムスライスの比率が上下する 9