Closed werunom closed 5 years ago
I have few updates. Since the above testing was done in hasty, I thought of doing a clear one this time. Also present these findings more coherently.
Scenario-1
I gave % !TEX root = workspace/Name Folder/Tex\ File.tex
The logs are below. As can be observed in the logs,
workspace\third-folder\present-file
) as root.workspace\first-folder\first-tex-file
as rootScenario-2
I gave % !TEX root = workspace/Name Folder/Tex File.tex
This time, I get the proper log reports saying the right file has been picked. So, looks like the magic-tex-root
command can have spaces and better not to delimit all spaces by a backward slash.
However, after sometime, it sets again the first-folder/first-file
as the root.
Scenario-3
With no tex-root
command, I get the following log.
Thought of providing another set of logs after sometime
Observations
Only in scenario-3, the response-lag was observed. This can readily be seen in the time taken for lintering the root file --- most of the time-period recorded for Linter for root file successfully finished
are close to 1 second. This corresponds with I observing the lag in editor not responding when I hit enter
In all the scenarios, eventually the root-file gets changed. This is surprising because the present working file has its own begin and end document
.
Update: lag in response was observed even with the command % !TEX root = workspace/Name Folder/Tex File.tex
Below are the logs. You can see towards the end the unusual long time for Linter for root file successfully finished...
Again not sure why the present the file is not getting picked as root even with the magic-tex-root command!
Another log-sample with high linting time for root file
You are stating that the root file search is problematic, which is not directly caused by the size of the tex files. If so, please provide a minimal working example. I cannot reproduce this problem.
In addition, when providing log, please disable linting if possible as it is producing a lot of noise. I am also not clear about what lag your are mentioning in the messages. In between which lines the lag happened? What did you do that might trigger a re-root-finding (e.g., typing)?
Excuse for being unclear.
Initial hunch
The initial motivation for checking the logs was lag in response. As mentioned in the first comment, when I am working on a tex file, I noticed at regular intervals (say, of few minutes) whenever I used to hit enter, the editor was taking noticable time to move the cursor to the next line.
To check if there are aspects that I can check in the logs, I noticed that the extension was repeatedly checking for root
file. In all the logs given above, re-root-finding
was triggered when I am just typing in the active-tex-file.
Since these two were happening, I presumed that the lag in response was due to re-root-finding operation. I might be wrong here.
Re-root-finding issue
Having said that, I thought of exploring the re-root-finding
further. When checking for different scenarios, I noticed that the current active file, which was initially considered as the root file, was later considered not as the root, but some other file (present in different folder) was considered as the root. Hence thought of reporting these findings.
To reproduce this with MWE, consider test.tex
% !TEX root = <absolute-path>/test.tex
\begin{document}
\section{first}
\section{second}
\end{document}
When this file is active, below is the log generated. (I have switched off the linter as you suggested). In this log, between [15:11:31]
and [15:12:23]
, I kept the editor idle --- did not do anything. As you can see, the re-root-finding
got triggered and the root file was changed. Is this expected?
As mentioned, I presumed that this re-root-finding might have something to do with lag-in-response. This might not be the case.
No, it was not expected. Looking into this issue as I accidentially re-produced it. Yet my triggering this bug involves changing the active editor to a non-tex editor (e.g., log, pdf). This will be fixed shortly. Does your provided log requires such an action?
@werunom Please try the latest main branch @ 376360198456b2f24824554e23b92e4643026333 and see if the root file changing problem persists. If it is addressed, I will go on with the lag.
No, it was not expected. Looking into this issue as I accidentially re-produced it. Yet my triggering this bug involves changing the active editor to a non-tex editor (e.g., log, pdf). This will be fixed shortly. Does your provided log requires such an action?
In my case, the re-root-finding was also triggered in other scenarios --- editing the tex file, clicking on the log, etc.
Coming to the latest fix, can you please guide me of how to use the latest build in vscode. I have not done this before.
Try this. There are some additional logs in the dev console.
Unzip this file to get a vsix file. In vscode, extension -> three dots -> Install from VSIX ...
Thanks. I will do so and get back to you with log results.
The updated fix did not solve the problem. Below is the log. Just by opening a tex file, (i) made it the root file and (ii) immediately the root file was changed
I cannot find the reason, nor can I reproduce with the minimal working example. Need to wait for others' analysis.
It seems that at :29 a re-find is triggered at no explicit user action. I sincerely don't understand why this happened.
Update: I was bit more observant this time.
I opened a file, and continued to work on it for sometime (writing, copy-pasting, etc.)
Then, I opened the log. That is when the re-root-finding
got triggered.
I have separated these two events by ====
in the below log.
Realising that the root file changes only when log is opened probably indicates that --- if I had continued to work, the re-rooting would not have happened. Probably that also answers why the re-find is triggered at no explicit user action
. Would this make sense?
Since I was not aware of it, probably all the above claims are false-alarms since all of them involves opening the logs and thus triggering the activity of re-rooting.
After working with the Master-version for sometime, I can confirm that the re-finding of root
is triggered only when I open the log.
Going back to the main issue which started all these, I still observe the lag. And this has been --- as the below logs show --- largely due to parsing
of the tex file on every small change.
Just thinking out loud: Has this implementation tested for performance? The current tex file is around 13000 words. Would not the lagging be more severe for a larger file?
@tamuratak It seems that the parsing at line 712 of manager.ts
is not done asynchronously. I did not find a way to resolve this. Can you please take a look?
If you use the same value of timeout
for latexParser.parse
in manager.ts
and setTimeout
in main.ts
, the parser is always running in the worst case. So, the value for latexParser.parse
should be a half or a third of the one for setTimeout
in main.ts
.
That is not the key problem. The parser takes ~500ms to parse my ongoing tex
, which renders a 8-page IEEE paper, with a beefy desktop. That means constant stutters between typing. What I was asking was on the possibility of making the parser faster, not how to fine tune the timeout: we are far from fine tuning things.
If there is no way of making it asynchronous to the main thread of the extension, and making it faster, then we can always set the timeout to something like 100ms
to minimize the visual distraction.
edit: but that just loses the reason of using a syntax parser instead of regex, which seems to be implemented with C, thus quite fast.
I am not sure what you mean by asynchronous to the main thread of the extension
. Node.js does not support multi-thread programming. Only the main thread always exists in the process of node.js. Worker Threads is still experimental.
You can run the parser in a different process using Cluster if you want.
edit: Using Child Process might be simpler in this case.
See #1647, an example of using workerpool package to make the parser run in a child process.
Just a side remark. I think we should add a configuration setting to deactivate parsing on document change and to delegate parsing to the file watcher, ie when the file is saved. It is important to make sure the extension remains little CPU demanding. As far as I am concerned I would rather have parsing triggered by save.
I agree with you @jlelong . Will add the config soon.
In the meantime, This still cannot resolve the stutter upon saving, though less frequently. I am thinking of a three-step process to alleviate the issue:
How do you think of this?
A side note: I noticed a --cache
flag in PEG.js CLI. Will this change the efficiency of the parser? @tamuratak
No as far as I tried. An error, Maximum call stack size exceeded
, sometimes happens if enabled.
@James-Yu have you tried #1647?
Not yet. I am investigating child_process.fork
to see if that works.
@tamuratak just checked the PR and it works really well! Feel free to merge when you think it is ready as it is still tagged as draft
.
The lag will be fixed in the next release. @werunom
@James-Yu @tamuratak --- Thanks for fixing this!
Am I correct to assume that the fix is in 8.0.7? I was having similar issues with 8.0.x but not since updating to 8.0.7.
@krupenja - even though 8.0.7 had some attempts, the positive fix was provided in 8.1.0. See the change-log for reference.
Disable all the other extensions except for LaTeX Workshop, and check that you still see this issue. [Required]
You still see this issue?: Yes
Describe the bug [Required] After the recent version bump to
8.0
, I have noticed a lag in response. Clarification about what I mean bylag in response
: when I am working on a tex file, I noticed at regular intervals (say, of few minutes) whenever I used to hitenter
, the editor was taking noticable time to move the cursor to the next line. This has never happened before invscode
andlatex-workshop
. Also, the tex file I am working is not that big --- it was around 13000 words. I have worked earlier with the same extension on files that are easily larger than this.To investigate, I disabled other extensions except the present one and I observed the same issue. So, I started checking the logs to see what is happening. I observed that the lag in editor response was happening whenever the extension was finding the
root
files.So, three issues/queries I have.
The lag was experienced frequently, every few minutes when the extension goes hunting for the root file. Have you and others experienced something similar?
The currently working tex-file has its own
begin
and\end{document}
. Also, I have given the magic-tex command stating that the tex file itself is the root. If this is the case, why is the extension does this:Found files that might be root, choose the first one...
- and goes through all sub-folders of the workspaceIs the extension not recognising the current file as
root
due to the spaces in the directory and file names? If I am working on, say,workspace/Name Folder/First Tex File.tex
, then I have tried both the% !TEX root
commands:workspace/Name Folder/First Tex File.tex
andworkspace/Name\ Folder/First\ Tex\ File.tex
both of them did not change the extension's behaviour.
Root file changed from <working-file present in the third subfolder> to <first tex file found in the first subfolder>
Instantiating a new file watcher for <first tex file found in the first subfolder>
Why is that the currently working file was not set as the root file?
Logs
LaTeX Workshop Output [Required]
[20:33:21] Linter for root file successfully finished in 0s 848ms [20:33:21] Linter log parsed with 5 messages. [20:33:21] Linter for active file successfully finished in 0s 71ms [20:33:21] Linter log parsed with 5 messages. [20:33:23] Linter for active file started. [20:33:23] Linter for active file running command chktex with arguments -wall,-n22,-n30,-e16,-q,-n8,-n44,-n38,-I0,-f%f:%l:%c:%d:%k:%n:%m [20:33:23] Linter for active file successfully finished in 0s 78ms [20:33:23] Linter log parsed with 5 messages. [20:33:24] Linter for root file started. [20:33:24] Linter for root file running command chktex with arguments -wall,-n22,-n30,-e16,-q,-n8,-n44,-n38,-f%f:%l:%c:%d:%k:%n:%m ,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V4.tex [20:33:24] Parsing /home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V4.tex [20:33:24] Found .bib file /home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/references.bib [20:33:24] File watcher: responding to change in /home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V4.tex [20:33:25] Linter for active file started. [20:33:25] Linter for active file running command chktex with arguments -wall,-n22,-n30,-e16,-q,-n8,-n44,-n38,-I0,-f%f:%l:%c:%d:%k:%n:%m [20:33:25] Found files that might be root, choose the first one: /home/Research/Notes/Bundle/Resume.tex,/home/Research/Notes/Writings/Archaeoastronomy/Teotihuacan.tex,/home/Research/Notes/Writings/Uncertainty of technology/Analysis of Substantial Equivalence.tex,/home/Research/Notes/Writings/Uncertainty of technology/Technological Uncertainty.tex,/home/Research/Notes/Philosophy Readings/Metaphysics/Objects - Quine.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 6.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 7.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 5.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 3.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 9.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 4.tex,/home/Research/Notes/Writings/Phd/Progress Reports/Progress report 8.tex,/home/Research/Notes/Writings/Phd/Proposals/Proposal 2 - Non-spatiotemporal interpretation of matter & causality in quantum physics.tex,/home/Research/Notes/Writings/Phd/Proposals/Proposal 1 - Material as Concrete V2.tex,/home/Research/Notes/Writings/Phd/Proposals/Proposal 4 - Physicality of quantum entities.tex,/home/Research/Notes/Writings/Phd/Thesis/0-Main.tex,/home/Research/Notes/Philosophy Readings/Philosophy of Science/Scientific objects/Scientific objects-Unobservables-theoretical.tex,/home/Research/Notes/Bundle/Configuration/latex/TitlePage.tex,/home/Research/Notes/Bundle/Configuration/latex/Tikz.tex,/home/Research/Notes/Writings/Phd/Writing/Physicality/Physical Structure of Entities - bkp.tex,/home/Research/Notes/Writings/Phd/Writing/Physicality/An enquiry of physicality 4.tex,/home/Research/Notes/Writings/Phd/Writing/Physicality/An enquiry of physicality 3.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V2.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V4.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single photons V1.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V3.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V4 - bkp1.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Substantial analysis of duality claims/Substantial analysis of duality claims of photon.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Different notions of duality/Different notions of duality.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of radiation/Interpretations of wave-particle duality - Einstein Planck Dirac.tex,/home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of radiation/Survey of wave-particle duality.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Theoretical and Physical interpretations of light quantum.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Analysis of photons in AC and MZ/Analysis of photons in AC and MZ.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/How to talk about photons/How to talk about photons.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/How to talk about photons/How to talk about photons - bkp - 1.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/How to talk about photons/How to talk about photons - 2.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Superposition and Interference/Interference of photons V2 - outline - bkp2.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Superposition and Interference/Interference of photons V2 - outline - bkp1.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Superposition and Interference/Interference of photons V2.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Superposition and Interference/Interference of photons V1 - outline - bkp.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Superposition and Interference/Interference of photons V2 - outline - bkp3.tex,/home/Research/Notes/Writings/Philosophy of Science/Scientific entities/Photons/Superposition and Interference/Interference of photons V2-bkp.tex [20:33:25] Root file changed from: /home/Research/Notes/Writings/Philosophy of Science/Duality/Duality of Single Photons/Duality of Single Photons V4.tex to /home/Research/Notes/Bundle/Resume.tex. Find all dependencies. [20:33:25] Root file changed -> cleaning up old file watcher. [20:33:25] Instantiating a new file watcher for /home/Research/Notes/Bundle/Resume.tex [20:33:25] Parsing /home/Research/Notes/Bundle/Resume.tex [20:33:25] Parsing /home/Research/Notes/Bundle/Configuration/latex/config.tex [20:33:25] Found .bib file /home/Research/Notes/Bundle/Configuration/Bibliographies.bib [20:33:25] Linter for root file successfully finished in 0s 771ms [20:33:25] Linter log parsed with 5 messages. [20:33:25] Adding /home/Research/Notes/Bundle/Resume.tex to file watcher. [20:33:25] Adding /home/Research/Notes/Bundle/Configuration/latex/config.tex to file watcher. [20:33:25] Linter for active file successfully finished in 0s 127ms [20:33:25] Linter log parsed with 4 messages.Desktop [Required]: