Hi everyone! I’m developing an Obsidian plugin that acts like a static site generator (similar to Hugo), converting Markdown into HTML using custom templates.
Performance Issue
I’m running into a bottleneck with template rendering, which is CPU-intensive:
-
Same code:
- ~5ms per page when run in a standalone Node.js environment
- ~30–50ms per page when run inside Obsidian
Workers Not Supported
I tried using Worker / worker_threads to offload CPU-heavy logic, but Obsidian’s environment seems to block that:
Error: Failed to construct 'Worker': The V8 platform used by this instance of Node does not support creating Workers
Question
What are the best practices for performing CPU-intensive operations in an Obsidian plugin, especially when multithreading isn’t available?
What I’ve Tried
- Breaking work into chunks with
setTimeout()to yield back to the event loop - Reporting progress during long tasks
- Simulating async processing — but no major performance improvement
Looking for Advice
- Any recommended strategies to speed up CPU-bound code in plugins?
- Any alternatives to Workers for parallel or non-blocking execution?