-
-
Notifications
You must be signed in to change notification settings - Fork 22
Improve performance for accessing files from IDOM_WEB_MODULES_DIR #4
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
Comments
@Archmonger I'm looking at what's required to implement this and its kind of ugly stuff. I'd mostly be copy-pasting code I don't really understand which makes me nervous about maintaining it going forward. I'm also still a bit skeptical that this will actually be a bottle neck. Given that, I think I'm going to hold off for now. If it does prove to be a real issue, we can revisit at that point. With that said, I think there are two simpler solutions to this problem of the dynamic files in
|
AsyncI agree that it should be async. Generally all functions and views that target Django 3.0+ should be async. That is, unless you're writing Django code that uses calls the DB (Django team is still working on async DB ORM). HTML tag parsingI also was having trouble following the django-compressor code, but I'll see if I can digest it to become maintainable. If not, I do have another idea in mind to accomplish the same thing. We could directly call all configured staticfile finders and, as you suggested before, do a regex match on all Bottleneck?To my understanding, all JS Web Modules should become apparent on the idom component's first call. If that is indeed the case then I'm not seeing any edge cases of this implementation. But, if for some reason IDOM does not deterministically collect all required web modules on first call, then we'd need to reasses. CachingI do support us caching the view. But, not all Django users run with any cache backends enabled, and additionally not all cache backends are So perhaps, use Django's |
Bottleneck?
The this in that statement referred to accessing the JS files. That is, that accessing the JS files using the "dynamic" approach (as apposed to being able to load them from a static dir) would become a bottleneck. For now, I think I'm going to make the function async, and add the basic caching with Since a static collection method would be a backwards compatible addition, I think I feel comfortable releasing with the aforementioned changes so I can move on to other things in |
If we do intend to implement this as a management command later, I've determined the relevant lines of code related to django_compressor. Although their code is severely lacking comments, I personally think it's fairly easy to follow. See Django Compressor Psuedocode
Future ImplementationSince we're leaving this for later, we're going to need to follow in django-compressor's footsteps of having a |
On the note of performance, we may also want to consider caching the output of |
This check should cover that since we avoid attempting an import if it's already in the set of imported modules. |
Ah, but one could use the same component more than once, so we could skip registration entirely if it's already there. Created an issue: #5 |
Caching the register function with What do you think? |
Progress UpdateA lot of this issue has been resolved. List of a few things that have been developed
Task remaining
|
I'm going to close this issue based on the title. The fully async web module fetching we have developed is good enough for now. Will create a separate issue specific to a new collect management command. |
IDOM_WEB_MODULES_DIR
contains JS modules that are dynamically added at runtime. Since JS files are typically loaded statically, it would be nice if we could improve how quickly these files can be accessed. There are three ways to do that:async
to avoid blocking while waiting on the file systemNotes
To implement the management command we could trace over all the templates and look for
idom_component
template tag nodes in order to figure out what modules to import so that we can trigger the collection of the JS files intoIDOM_WEB_MODULES_DIR
. Then once they've been collected those files can be copied into a permanent static location.To do this we can take inspiration from the django compressor library which takes a similar approach. See the
COMPRESS_OFFLINE
setting to figure out how they're doing it. Also thecompressor.offiline
module contains uniform interfaces for parsing template syntax for Django and Jinja that we might want to copy (with the latest LICENSE, what to do aboutAUTHORS
file?).Conversation originated from: this comment
The text was updated successfully, but these errors were encountered: