Skip to content

Conversation

@Scheremo
Copy link
Contributor

@Scheremo Scheremo commented Oct 6, 2025

Reduce filesystem I/O overhead caused by repeated re-opening and reparsing of project files in the Verilog LSP server when using the -C option. For a large, SoC-scale project this approach reduces parsing time from ~1s to 0.75s.
This implementation also correctly indexes the editor-state rather than the file system state of the main buffer.

  • Introduced shared projectDriver: A persistent slang::driver::Driver is now created once per project and passed to all VerilogDocument instances to reuse loaded files and avoid redundant disk access.
  • Refactored VerilogDocument initialization:
    • Removed per-buffer command file parsing and main-file filtering logic.
    • Added setTopModules() and copyBuffers() helpers to extract top-level modules and reuse in-memory buffers from projectDriver instead of reading from disk.
  • Inheritance of project context:
    • Copied defines/undefines directly from the shared driver.
    • Library search directories are now applied once at construction.
  • VerilogTextFile integration:
    • Added initializeProjectDriver() to parse all command files once and hold a shared driver reference for reuse.

@Scheremo Scheremo force-pushed the pr-lsp-projectdriver branch 3 times, most recently from fc58142 to 3e93c5f Compare October 6, 2025 14:31
@Scheremo Scheremo marked this pull request as ready for review October 6, 2025 15:17
@Scheremo Scheremo requested a review from uenoku October 7, 2025 06:53
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question on shared pointer but otherwise LGTM

@Scheremo Scheremo force-pushed the pr-lsp-projectdriver branch from 18429d7 to ebf4c6d Compare October 8, 2025 08:00
Reduce filesystem I/O overhead caused by repeated re-opening and reparsing of project files in the
Verilog LSP server when using the `-C` option. For a large, SoC-scale project this approach reduces
parsing time from ~1s to 0.75s.
This implementation also correctly indexes the editor-state rather than the file system state of the main buffer.

- **Introduced shared `projectDriver`:**
  A persistent `slang::driver::Driver` is now created once per project and passed to all
  `VerilogDocument` instances to reuse loaded files and avoid redundant disk access.
- **Refactored `VerilogDocument` initialization:**
  - Removed per-buffer command file parsing and main-file filtering logic.
  - Added `setTopModules()` and `copyBuffers()` helpers to extract top-level modules and reuse in-memory buffers from `projectDriver` instead of reading from disk.
- **Inheritance of project context:**
  - Copied defines/undefines directly from the shared driver.
  - Added placeholder for include path copying (TODO).
  - Library search directories are now applied once at construction.
- **VerilogTextFile integration:**
  - Added `initializeProjectDriver()` to parse all command files once and hold a shared driver reference for reuse.
@Scheremo Scheremo force-pushed the pr-lsp-projectdriver branch from ebf4c6d to bafc2ae Compare October 8, 2025 08:22
@Scheremo
Copy link
Contributor Author

Scheremo commented Oct 8, 2025

Question on shared pointer but otherwise LGTM

Thanks for the review! I think I addressed the points you raised, but I'll keep this open for a day or so before merging, just in case you'd like to have another look.

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Scheremo Scheremo merged commit 2198ac4 into llvm:main Oct 9, 2025
7 checks passed
@Scheremo Scheremo deleted the pr-lsp-projectdriver branch October 21, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants