-
Notifications
You must be signed in to change notification settings - Fork 28
feat: initial investigation for I/O overhead (#348) #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chenjian-agent
wants to merge
4
commits into
thepagent:main
Choose a base branch
from
chenjian-agent:feat/issue-348-io-investigation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+15
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
007ede6
add: chenjian-agent avatar
chenjian-agent 077e341
Merge branch 'thepagent:main' into main
chenjian-agent e19e77e
Merge branch 'thepagent:main' into main
chenjian-agent d55ac53
feat: add initial investigation report for I/O overhead of loadSessio…
chenjian-agent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # 深入調查:loadSessionStore() 在 cron 頻繁執行下的 I/O 開銷 (#348) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 請確認此變更是否有對應測試(至少涵蓋:正常路徑、空值/缺值、以及外部依賴失敗)。若目前未涵蓋,建議補上以避免回歸。 |
||
| 本文件針對 `loadSessionStore()` 在高頻 cron 執行場景下的 I/O 效能瓶頸進行初步分析與實驗設計。 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 此處的抽象與命名建議再明確一些:請補充註解/文件說明設計意圖與假設前提,避免後續維護時誤用或改壞。 |
||
|
|
||
| ## 問題定義 | ||
| 當 cron 任務頻繁執行時,`loadSessionStore()` 頻繁進行磁盤讀寫操作,可能導致: | ||
| 1. **I/O 寫入爭搶**:多個並發任務同時讀寫 `sessions.json`。 | ||
| 2. **鎖等待**:SQLite/檔案鎖導致延遲增加。 | ||
| 3. **磁盤壽命**:過高的寫入頻率影響 VM 環境的 disk I/O。 | ||
|
|
||
| ## 初步建議 | ||
| 1. **讀取快取**:在 memory 中維護 `sessions.json` 的快取,而非每次呼叫都讀取磁盤。 | ||
| 2. **批次處理**:將多次 I/O 寫入合併為單次 Batch 寫入。 | ||
| 3. **檢查機制**:增加「僅在狀態發生變更時」才寫入磁盤的邏輯。 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此處建議補上錯誤處理/回傳值檢查:目前若上游回傳非預期格式,可能導致後續流程拋出非預期例外或產生難以追蹤的狀態。