⚡ Bolt: Optimize GetPerAppWritableRoot string sanitization - #68
Conversation
Replace O(N^2) LINQ array lookup and repeated Path.GetInvalidFileNameChars() array allocations with cached SIMD-accelerated SearchValues<char> and string.Create. Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
📦 Build artifacts —
|
| Platform | Download |
|---|---|
| Windows (win-x64) | sharpemu-win-x64-d417c21 |
| Linux (linux-x64) | sharpemu-linux-x64-d417c21 |
| macOS (osx-x64) | sharpemu-osx-x64-d417c21 |
From build run #140. Downloads require a GitHub login and expire after 90 days.
💡 What
Optimized application name path sanitization in
KernelMemoryCompatExports.GetPerAppWritableRoot()by replacingPath.GetInvalidFileNameChars().Contains(...)and LINQ.Select().ToArray()with a static SIMD-acceleratedSearchValues<char>instance andstring.Create.🎯 Subsystem & Bottleneck
SharpEmu.LibsKernel Exports (KernelMemoryCompatExports.cs)GetPerAppWritableRoot()was allocating a newchar[]array on every invocation viaPath.GetInvalidFileNameChars(), followed by anSelectprojection that evaluatedinvalidChars.Contains(ch)and allocated a temporary array before creating a new string.📜 Git & Contributor Context
GetPerAppWritableRoot()is invoked during kernel initialization and directory resolving for writable app directories (download0, etc.).📊 Measured Performance Impact
GetInvalidFileNameChars()) toSearchValues<char>.string.Createallocates only the target string buffer once.🔬 Verification Checklist
dotnet build SharpEmu.slnx.dotnet test SharpEmu.slnx.dotnet format SharpEmu.slnx --verify-no-changes --include src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs tests/SharpEmu.Libs.Tests/Kernel/KernelMemoryCompatExportsTests.cs.PR created automatically by Jules for task 16479707384063025503 started by @manupawickramasinghe