Skip to content

စာတမ်းဖြူ ​

ဤစာရွက်စာတမ်းသည် WSL Dashboard ၏ architecture design၊ technology selection နှင့် အဓိကလုပ်ဆောင်ချက်များ၏ နောက်ခံ implementation logic ကို နက်ရှိုင်းစွာ လေ့လာထားပြီး developer များနှင့် အဆင့်မြင့်အသုံးပြုသူများအတွက် နည်းပညာ နက်ရှိုင်းသော ရှုထောင့်ကို ပေးစွမ်းရန် ရည်ရွယ်သည်။

1. Architecture ခြုံငုံသုံးသပ်ချက် ​

WSL Dashboard သည် classical reactive UI-driven + asynchronous backend tasks architecture ကို ကျင့်သုံးပြီး Rust ၏ type system နှင့် ownership model ကို အသုံးပြု၍ memory safety နှင့် high concurrency performance ကို သေချာစေသည်။

အဓိက အစိတ်အပိုင်းများ ​

  • Frontend (UI): Slint declarative interface ကို အခြေခံသည်။ UI thread သည် rendering နှင့် user interaction ကို တာဝန်ယူသည်။
  • Backend (Runtime): Tokio asynchronous runtime ကို အခြေခံသည်။ System commands (CLI) များကို ဖြန့်ဝေခြင်း၊ လုပ်ဆောင်ခြင်း၊ file I/O နှင့် network listening တို့ကို တာဝန်ယူသည်။
  • Communication: UI thread နှင့် asynchronous tasks များသည် Channel (MPSC) နှင့် Shared State (Arc/Mutex/RwLock) မှတစ်ဆင့် ထိရောက်ပြီး thread-safe ဖြစ်သော ဆက်သွယ်မှုကို ပြုလုပ်သည်။

2. Technology Selection အကြောင်းရင်းများ ​

ဘာကြောင့် Rust ကို ရွေးချယ်သနည်း? ​

  • စွမ်းဆောင်ရည်: Zero-cost abstraction ဖြစ်ပြီး native machine code အဖြစ် compile လုပ်ပြီး GC jank မရှိပါ။
  • Memory Safety: Compile time တွင် buffer overflow နှင့် data races များကို ဖယ်ရှားနိုင်ပြီး system-level operations (disk migration၊ network configuration ကဲ့သို့) ပါဝင်သော tool များအတွက် အလွန်အရေးကြီးသည်။
  • Binary Size: Dependencies အားလုံးကို static link လုပ်ပြီး single-file portable executable program တစ်ခု ထုတ်လုပ်သည်။

ဘာကြောင့် Slint + Skia ကို ရွေးချယ်သနည်း? ​

  • Declarative Syntax: Interface description နှင့် logic ကို ခွဲထားပြီး code ကို ထိန်းသိမ်းရန် လွယ်ကူသည်။
  • Skia Rendering: GPU acceleration ကို တိုက်ရိုက် အသုံးပြု၍ (Skia engine မှတစ်ဆင့်) sub-pixel level ကြည်လင်မှုရှိသော text နှင့် ချောမွေ့သော animation effects များကို ပေးစွမ်းသည်။
  • အနိမ့်ဆုံး Overhead: Electron သို့မဟုတ် WPF နှင့် နှိုင်းယှဉ်ပါက Slint ၏ runtime overhead သည် အလွန်သေးငယ်သည်။

3. အဓိကကျသော နည်းပညာ Implementation များ ​

3.1 WSL Instance ရှာဖွေခြင်းနှင့် ခွဲခြမ်းစိတ်ဖြာခြင်း ​

Application သည် wsl.exe --list --verbose ကို ခေါ်ယူပြီး ၎င်း၏ output (UTF-16 encoding ကို ကိုင်တွယ်ခြင်း) ကို ခွဲခြမ်းစိတ်ဖြာခြင်းဖြင့် instance အခြေအနေများကို real-time ရယူသည်။

  • အောက်ခြေ Decoding: Region settings အမျိုးမျိုးရှိသော Windows environment များတွင်ပါ output ကို မှန်ကန်စွာ ခွဲခြမ်းစိတ်ဖြာနိုင်ရန် သေချာစေသော ထိရောက်သော encoder/decoder ကို ကိုယ်တိုင်တီထွင်ထားသည်။
  • State Synchronization: Time-based polling + operation-triggered နှစ်မျိုးပါသော synchronization mechanism ကို ကျင့်သုံးသည်။

3.2 Disk Image Migration (VHDX Move) ​

Migration လုပ်ဆောင်ချက်သည် WSL ၏ import/export mechanism ကို အသုံးပြုသော်လည်း အဆင့်မြင့် abstraction နှင့် atomic ပြုလုပ်ထားသည်။

  • Transactional အာမခံချက်: Migration မစတင်မီ application သည် Mutex ဖြင့် target distribution ကို lock လုပ်ပြီး concurrent operation ကြောင့် data corruption ဖြစ်ခြင်းကို ကာကွယ်သည်။
  • အလိုအလျောက် Register: Migration ပြီးစီးပြီးနောက် application သည် VHDX path ကို အလိုအလျောက် redirect လုပ်ပြီး distribution ကို ပြန်လည် register လုပ်ပေးပြီး user က လက်ဖြင့် ဝင်ရောက်စရာမလိုပါ။

3.3 Port Forwarding နှင့် Firewall အလိုအလျောက်လုပ်ခြင်း ​

Network လုပ်ဆောင်ချက်သည် ရိုးရိုး netsh interface portproxy call သာမဟုတ်ပါ။

  • Rule Lifecycle Management: Application သည် ရှိပြီးသား firewall rules များကို အလိုအလျောက် ရှာဖွေတွေ့ရှိသည်။ User က forwarding ဖန်တီးသည့်အခါ application သည် Windows API သို့မဟုတ် CLI ကို အသုံးပြု၍ inbound exception rules များကို တစ်ပြိုင်တည်း ဖန်တီးပေးသည်။
  • IP အလိုအလျောက် ရယူခြင်း: wsl hostname -I ၏ result ကို ခွဲခြမ်းစိတ်ဖြာပြီး host နှင့် instance အကြား virtual network IP များကို အလိုအလျောက် map လုပ်ပေးသည်။

3.4 USBIP ပေါင်းစည်းခြင်း ​

usbipd-win ၏ command line interface ကို အသုံးပြုသည်။

  • Privilege Elevation Handling: Bind operation သည် administrator permission လိုအပ်ပြီး backend logic သည် elegant သော UAC privilege elevation request forwarding ကို အကောင်အထည်ဖော်ထားသည်။
  • State Machine: USB device connection state machine တစ်ခုကို အတွင်းပိုင်း ထိန်းသိမ်းထားပြီး Attach/Detach process ကို ခြေရာခံနိုင်စေသည်။

3.5 Resource Monitoring နှင့် Lightweight ပြုလုပ်ခြင်း ​

Application သည် Windows native APIs (ဥပမာ GetProcessMemoryInfo) ကို ခေါ်ယူ၍ ၎င်း၏ resource usage ကို စောင့်ကြည့်သည်။

  • အလွန် Lightweight: Tray silent mode တွင် application သည် မလိုအပ်သော UI resources များကို စေတနာ့ဝန်ထမ်းအနေဖြင့် လွှတ်ပေးသည်။ အင်္ဂလိပ်ကဲ့သို့သော standard character sets များအတွက် memory usage သည် 10MB အထိ နိမ့်နိုင်သည်။ CJK ကဲ့သို့သော ရှုပ်ထွေးသော character sets များအတွက် ကြီးမားသော font rendering cache များ load လုပ်ရသောကြောင့် usage သည် 38MB ခန့်ရှိသည်။

4. Performance Optimization ညွှန်းကိန်းများ ​

ညွှန်းကိန်းTarget/ActualOptimization နည်းလမ်း
Startup Speed< 500msSlint interface ကို pre-compile လုပ်ပြီး runtime parsing ကို လျှော့ချသည်။
Base Memory (Tray)~10MBBackground polling frequency ကို အနည်းဆုံးဖြစ်စေပြီး rendering cache များကို လိုအပ်သလို လွှတ်ပေးသည်။
CPU Usage (Idle)< 0.1%Windows event-driven model ကို အသုံးပြု၍ empty loop polling ကို ရှောင်ကြဉ်သည်။
Rendering FPS60 FPSSkia GPU acceleration နှင့် sub-pixel anti-aliasing rendering။

5. Backend Task ဖြန့်ဝေခြင်း Logic ​

UI ၏ ချောမွေ့မှုကို သေချာစေရန် အချိန်ကုန်သော operation အားလုံး (VHDX export ကဲ့သို့) ကို asynchronous tasks များမှတစ်ဆင့် ဖြန့်ဝေသည်-

  1. Request Encapsulation: UI thread သည် user operation ကို Command message အဖြစ် ထုပ်ပိုးသည်။
  2. Message Channel: tokio::sync::mpsc မှတစ်ဆင့် background task handler သို့ ပို့သည်။
  3. State Feedback: Background task ပြီးစီးပြီးနောက် callback သို့မဟုတ် state sharing မှတစ်ဆင့် UI ကို update လုပ်သည်။ ဤဒီဇိုင်းသည် GB ဂဏန်း backup tasks များကို လုပ်ဆောင်နေချိန်တွင်ပင် interface သည် user clicks များကို real-time တုံ့ပြန်နိုင်ကြောင်း သေချာစေသည်။

6. Security ထည့်သွင်းစဉ်းစားချက်များ ​

  • Atomic Operations: အဓိကကျသော instance uninstall နှင့် migration အတွက် pre-validation ကို အကောင်အထည်ဖော်ထားသည်။
  • UAC Privilege Elevation Management: USB device bind ကဲ့သို့ လိုအပ်သည့်အခါမှသာ permission ကို တောင်းခံပြီး least privilege principle ကို လိုက်နာသည်။
  • Local Storage: Configuration ကို local ~\.wsldashboard တွင်သာ သိမ်းဆည်းပြီး cloud synchronization လုံးဝမပြုလုပ်ပါ၊ user privacy ကို ကာကွယ်သည်။