RFC: Introduce bundle serve
command.
#1195
Open
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.
This pull request adds a new
bundle serve
command, an interactive version ofbundle cat
. It allows querying the contents of multiple files without spawning a new process each time.Motivation
While working on TeXpresso, a real-time LaTeX file previewing tool, we've encountered a bottleneck in our current workflow. It is possible to use Tectonic as a TeX distribution via the
bundle cat
command, but querying the contents of multiple files spawns a new process each time and leads to performance issues. We propose introducing a newbundle serve
command to address this problem.Background
TeXpresso is an experimental tool that allows users to preview LaTeX files in real-time. It achieves using a patched XeTeX and a specialized viewer. You can see it in action with Vim, Emacs and VSCode. The viewer requires a TeX distribution, which is where Tectonic comes in. We started by using
bundle cat
, but we need a more efficient solution.Proposal
The
bundle serve
command is an interactive version ofbundle cat
that allows querying the contents of multiple files without spawning a new process each time. To achieve this, we need to delimit the different requests.We implemented a simple protocol to stream all contents over a single stream:
bundle serve
reads a list of file names, one per line (delimited by\n
).bundle serve
responds with a 9-byte header followed by a payload:C
for contents,P
for path, orE
for errors.C
indicates the contents of the requested file.P
indicates a path on the local file system where the requested file can be found.E
indicates an error message explaining why the request failed.Alternative
If a more complex protocol is not desirable, a simpler line-based protocol reading file names and writing either paths or error messages would be sufficient. This approach is similar to
kpsewhich -interactive
(with improved error handling).Conclusion
We believe introducing the
bundle serve
command and its accompanying protocol would significantly improve the performance of TeXpresso and, potentially, other tools that rely onbundle cat
. We're open to feedback and alternative solutions.