-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proof of concept] In-built Latex compilation #119
Comments
OK @James-Yu that's updated now! Sorry I went off into the wilderness to work on this for a few weeks, really interested to hear what you think! |
Reporting in as tester. I certainly know secondary PCs where "latex-on-demand installation" would be beautiful. |
run 2 ieee template conf papers and a beamer presentation through, so far nothing out of the ordinary, and the installation takes up 49M. |
That's great to hear @tmblazek, thanks so much for the feedback. Few Q's if you don't mind:
|
Edit: And point 2. was for two runs. if that isn't needed it's about half, so negligible. |
Nicely done! Let me think how we can integrate that in a non-intrusive way... |
Thanks @James-Yu! Yes I've been thinking about this, and this would be my current suggestion:
which of course would default to false, and be clearly documented as a beta feature. For simplicity, for now I would say that enabling latexjs is a binary choice. If it's on, the usual latex toolchain setting is ignored, and instead latex workshop will call the If we did this, and did some testing with a few beta testers without major issues, we could role it out in an update to the marketplace, but we could only mention it's existence in the changelog (and be very clear it's a beta!). Some of our more technical passionate users would perhaps see it in the changelog and give it a go, and be able to offer us feedback. I don't think we should mention it in the README at all until it's undergone more testing, we only want more technical people to give it a go until we are sure it works well. The nice thing with this approach in my opinion is that:
I would also suggest we look at: as an example of an extension that downloads a good about (50MB or so I think) of support files on launch. |
I was trying to implement the said feature but had a problem. It seems that the nodejs bundled in vscode is not accessible from the extension. Any idea? @jabooth |
I had success using 'process.execPath' at least on macOS: https://nodejs.org/api/process.html#process_process_execpath Is this what you tried @James-Yu? |
It points to the executable binary of vscode on my Win. I need to find out if it can be used as a nodejs executable. edit: |
How about 'child_process.fork'? https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options |
Seems not working well, const currentProcess = cp.fork(path.resolve(path.dirname(root), 'latex.js'), ['install'])
currentProcess.on('error', err => {
console.log(err.message)
})
currentProcess.on('exit', (code, signal) => {
console.log(code, signal)
}) outputs |
I close this issue. Feel free to reopen if any progress. |
My experiments with shipping a cross-platform minimal LaTeX toolchain have gotten pretty far now, and I have a working prototype:
https://github.com/latexjs/latexjs
The README there hopefully does a reasonable job of explaining the idea of the project, and what it presently can and cannot do. I'll now try and break down what this is and what I think we could do with it wrt LaTeX Workshop:
What is Latexjs?
To summarise, the idea is to make a variant of TeX Live which has the following properties:
The 'binaries' (
pdflatex
etc) are actually Node JS modules (cross compiled with Emscripten). This has three benefits:Only the required exact files from TeX Live are downloaded for compilation. This is a remarkably small amount in my experience. Even working across different packages, I don't think most users Latexjs 'installs' would go above 100MB for everything. Mine is currently 42MB.
The whole toolchain is in one directory (
~/.latexjs
by default). Removal is as simple as deleting that directory. We do not run an installer, touch the registry in windows, or the$PATH
in UNIX.Updates are handled by the toolchain itself, including upgrades between TeX Live versions. All files are checksummed so we can verify users installations and have easy reliable upgrades.
How does this fit in to LaTeX Workshop?
The above properties change the dynamic of installing a LaTeX distribution considerably. 'Installation' is the same across all platforms, and only downloads around 5MB of files to a single directory that can be easily removed. After install we can depend on having a Latex compile toolchain that works exactly the same way across all platforms. If we had confidence such a solution worked reliably and in a performant manner, it could be possible for LaTeX Workshop to include support for downloading and managing Latexjs automatically, so for end users Latex compilation 'just works' with LaTeX Workshop installed and nothing else.
What are the current downsides/limitations?
Latexjs is untested. I've been trying it out on my macOS/Linux/Windows 10 boxes, but until it's been tested by some intrepid beta testers in more scenarios it's hard to know if there are edge cases we haven't considered.
Performance is not as good as native. Presently it's around 2-3x slower than using native solutions. This will improve quite significantly with WASM (Web Assembly) as currently we pay a fairly large startup cost in interpreting the asm.js code. I'm also no expert on Emscripten, and I'm sure we can get someone with more expertise to help us profile and get it faster. I think we can aim realistically for a sub 1.5x performance penalty..which given the significant upsides of having a turnkey solution, might be enough for many users to consider this instead of having to install maintain and update a full Latex installation.
Servers are required. I'm currently paying to run three $5/month instances whilst we test all this. I don't think the running costs will be massive (everything is compressed and only the absolute minimal required is presently downloaded), but longer term I would have to figure out a model to keep this running and up to date for the community if we feel it is useful.
So what is this issue about then?
For now, Latexjs can be tested with LaTeX Workshop without any modification to the extension. To test this, users can just follow the installation instructions in the README, and then set their toolchain configuration as follows:
macOS example:
Windows example:
A few notes:
node
interpreter on the$PATH
. If we were to integrate with LaTeX workshop we would use thenode
interpreter shipped with VS Code instead.I'm basically raising this issue to see if others think that this approach is interesting and something we should pursue. I would love it if others who were willing started to test out Latexjs and report issues for anything that doesn't work (please report on latexjs/latexjs and not here!). Beware this is a beta, so backup first and ideally test in a VM! I've been using it extensively the last few weeks without issue though.
If we find that people like the model and find that in testing it's working well, we could consider moving forwards with 'productising' it into something that just works.
Really interested to hear people's thoughts!
The text was updated successfully, but these errors were encountered: