Skip to content
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

Only watch what we need to #25

Open
tlienart opened this issue Apr 5, 2019 · 4 comments
Open

Only watch what we need to #25

tlienart opened this issue Apr 5, 2019 · 4 comments
Assignees
Labels

Comments

@tlienart
Copy link
Collaborator

tlienart commented Apr 5, 2019

This is not urgent. I'm just thinking that at the moment, if we trigger lots of requests, lots of files will be watched for changes. This makes sense if all the requests come from new tabs. But otherwise doesn't (e.g. if it's the same tab asking different things we should only really track the file that is currently being watched).

Watching files is very cheap though so not a big deal and even in the case of a huge website, we'd basically have to do hundreds of thousands of requests and modify all these files for it to maybe be a bottleneck.

Suggestion: a doable intermediate step which would feel cleaner is to stop watching files for which there is no associated viewer.

@tlienart tlienart added low priority enhancement New feature or request labels Apr 5, 2019
@asprionj
Copy link
Contributor

asprionj commented Apr 5, 2019

Suggestion: a doable intermediate step which would feel cleaner is to stop watching files for which there is no associated viewer.

This would be straightforward for HTML files. For all other files, there's IMO two options:

  • The information about the requester (tab / worker) is in the HTTP request. Don't know if it is there anyways (I guess not) or whether we could add it, e.g. by sending a cookie along with the HTML...
  • The server parses the HTML file for any files that are linked to it. Is there a HTML library in Julia doing this already...? Then, we could un-watch also all files that are associated with a HTML file, once that HTML file is not viewed anymore.

@tlienart
Copy link
Collaborator Author

tlienart commented Apr 6, 2019

  1. yeah so I think we can implement the simple stuff for HTML files (i.e. check if the corresponding wss is empty and if so remove it from watchefiles )
  2. parsing of HTML can be done with Gumbo.jl potentially.

I think the first one we can do now and could open another issue for a future improvement where we'd do the other one. It's a minor thing and wouldn't affect performances (apart from extreme cases).

@asprionj
Copy link
Contributor

asprionj commented Apr 6, 2019

It's not only about performance. One could be working on different HTML files, have them open in different browser windows that he watches at the same time (e.g. both on second screen). He then changes a file that's only used in one of the HTML files, but both update -- this might irritate, since one then usually assumes that the change actually affected both views.

But I agree, for first announcement doing it for HTML files is enough. Gumbo would provide a major piece of the final solution; we could then just traverse the tree and look only at tags that may reference files.

@tlienart tlienart self-assigned this Apr 9, 2019
@fonsp
Copy link
Collaborator

fonsp commented Mar 25, 2022

I think that Gumbo.jl would not be enough, because CSS and ES6 can import recursively, so you would also need parsers for those, which is probably beyond the scope

If the cost of file watching becomes a concern, I would go for #124 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants