Eel: eel.init takes 20seconds

Created on 14 Sep 2020  路  10Comments  路  Source: ChrisKnott/Eel

Describe the problem
In Raspbian Stretch, Python 3.5 is the highest supported version. But for eel Python 3.6 is required. So, I looking at tutorials I compiled Python 3.6 for Raspbian Stretch and got eel working but the line "eel.init" is taking 20 seconds.

How can I debug this issue?

Desktop (please complete the following information):

  • OS: Raspbian Stretch
  • Browser Chromium
help wanted

Most helpful comment

Still too long IMO. Maybe we should be hashing the file, and caching parse results, so that it's faster if the file hasn't changed.

All 10 comments

eel.init runs through the provided directory and parses files to pull out Javascript function names. If you're sure that is taking 20 seconds (I'm surprised), my first guess would be that you're pointing it at a massive directory and so the parsing is taking ages. Is that possible?

Otherwise you can debug it with the normal tools, eg pdb/ipdb, by setting a trace in the Eel library code for the init function to see exactly what's going on.

@samuelhwilliams Hello Samuel,
I also had the same guess and I did find some files which were in the range of 75MB. So, I removed them and tried, but it did not help.

The python I am using is not available for Raspbian Stretch and I had to compile it from the source. I think this could have played a major part in it. I will try multiple versions of Python3 and see if there's any improvement, before I try the pdb/ipdb.

A very quick (and dirty) check might be to insert a print(name) statement before or just after https://github.com/samuelhwilliams/Eel/blob/master/eel/__init__.py#L111 so that you can quickly see what files are getting checked/processed. Good to know that you've eliminated some of the large files already, but I wonder if there aren't still more. Have you tried pointing it at a separate directory that only contains the raw HTML/JS/CSS files you need and nothing else?

P.S. Eel is only officially supported on 3.6, but depending on your use-case and how much maintenance it needs, you might be able to get away with using it on 3.5 - so possibly worth giving that a shot as well? Obviously not if that's a production use-case though.

The reason for the whitelist of file extensions was to speed up this bit. Previously I was making a map app which had a folder with hundreds of OpenStreetMap tile images, and it was taking a long time to start up.

I also suggest Sam's debugging idea; you can also print time.perf_counter() if you don't want to watch it

@samuelhwilliams
I tried to find out which file(s) were causing the initialization to be slow. It turns out that there was one javascript file which was taking 12s and another javascript file which was taking 6s.

I decided not to use the 6s javascript file, and for the 12s javascript file I used the minified version.
After doing this, the initialization time has come down to 6s.

Now, that I know the minified versions of javascript file have great impact on the initialization, I will try to minify every javascript file.

Still too long IMO. Maybe we should be hashing the file, and caching parse results, so that it's faster if the file hasn't changed.

Out of curiosity @shrsulav, how big are your JS files?

The size itself does not seem big. The unminified version is around 600kB and minified version is 220kB. The number of lines of code is high though. Around 20k lines of code.

@samuelhwilliams Earlier you had mentioned, there's a way to use eel with python 3.5. Can you provide the details on how to do that?

I think should add a allow prefix argument in eel.init() if need.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HorrifyingMonkey picture HorrifyingMonkey  路  4Comments

logxseven picture logxseven  路  6Comments

abdurahman-shiine picture abdurahman-shiine  路  3Comments

ssekuwanda picture ssekuwanda  路  3Comments

ghost picture ghost  路  6Comments