linked-swissbib / vufind

A library resource discovery portal designed and developed for libraries by libraries
GNU General Public License v2.0
1 stars 2 forks source link

less compilation is slow #3

Closed ltog closed 8 years ago

ltog commented 9 years ago

Calling

php /usr/local/vufind/httpd/util/cssBuilder.php

is quite slow. It takes about a minute for each run. It seems all .less files are always processed. Maybe this could be speeded up using make or similar?

Unfortunately, https://github.com/linked-swissbib/vufind/blob/vfsb/linked/util/cssBuilder.php is quite opaque...

@guenterh @sschuepbach Any idea?

guenterh commented 9 years ago

Yes it's not really fast but until now we use it for all our scenarios. (includes deployment for production). Yes, it looks up all the theme directories for .less files

On the VuFind list you can already find discussions for alternatives. If I'm not wrong similar to your suggestion.

At the moment I don't want to change the mechanism for swissbib (classic) because it's additional work (we already have enough...) and I want to be compatible with the VuFind core workflows and mechanisms if there is not a strong reason for forks.

Günter

ltog commented 8 years ago

Since this really slows down the development of our web front-end, I took a closer look at this.

The output we see when calling https://github.com/linked-swissbib/vufind/blob/vfsb/linked/util/cssBuilder.php is generated by https://github.com/linked-swissbib/vufind/blob/vfsb/linked/module/VuFindTheme/src/VuFindTheme/LessCompiler.php .

In LessCompiler.php \Less_Cache::Regen() is used (see https://github.com/linked-swissbib/vufind/blob/745a14a04e24615b8e0be3766b74530b97432b69/module/VuFindTheme/src/VuFindTheme/LessCompiler.php#L205 ). However, its description indicates, that this is unsuitable:

Force the compiler to regenerate the cached css file

( https://github.com/linked-swissbib/vufind/blob/745a14a04e24615b8e0be3766b74530b97432b69/vendor/oyejorge/less.php/lib/Less/Cache.php#L134 )

The GitHub repository where this code comes from also mentions caching ( https://github.com/oyejorge/less.php#caching ). I suspect, the code is used wrongly.

ltog commented 8 years ago

On the VuFind mailing list someone posted a Makefile, which may be useful: http://sourceforge.net/p/vufind/mailman/message/33686762/

ltog commented 8 years ago

@guenterh @marahellstern Ich habe eine Änderung am Code vorgenommen, welche die less-Kompilation erheblich beschleunigen sollte (Commit https://github.com/linked-swissbib/vufind/commit/6b459e8b3a935f4ac31c9967d06ec4d401b05a9f ). Ihr könnt das mal pullen und testen. Das Vorgehen zum Kompilieren von less ist immer noch genau dasselbe, nämlich das Aufrufen von

php /usr/local/vufind/httpd/util/cssBuilder.php

So wie ich den Befehl notiert habe, muss man dafür nicht in ein bestimmtes Verzeichnis wechseln.

@guenterh Die Änderungen, die ich vorgenommen habe, sind sehr klein. Im Code war das (vermutlich) alles schon richtig aufgegleist, nur wurde am Schluss die falsche Funktion (Regen() anstelle von Get(), das jedes Mal ein Neukompilieren erzwingt) aufgerufen, soweit ich das sehen konnte. Auch im vufind Repo ist das noch so enthalten: https://github.com/vufind-org/vufind/blob/9e3a406c41636e5448c6d97f2aeb53c669a94cdd/module/VuFindTheme/src/VuFindTheme/LessCompiler.php#L205 Vielleicht können wir mal schauen, wie stabil das läuft und ggf. auch dort einfliessen lassen.

@guenterh Ich habe vufind im development Mode laufen. Vermutlich deshalb sehe ich zwei Warnungen beim Aufruf von cssBuilder.php:

$ php /usr/local/vufind/httpd/util/cssBuilder.php 
Processing bootprint3
    compiling 'compiled.less' into '/usr/local/vufind/httpd/themes/bootprint3/css/compiled.css'
        0.014309883117676 sec
PHP Warning:  scandir(/usr/local/vufind/httpd/themes/bootprint3/css/less/): failed to open dir: No such file or directory in /usr/local/vufind/httpd/vendor/oyejorge/less.php/lib/Less/Cache.php on line 245
PHP Stack trace:
PHP   1. {main}() /usr/local/vufind/httpd/util/cssBuilder.php:0
PHP   2. require_once() /usr/local/vufind/httpd/util/cssBuilder.php:32
PHP   3. Zend\Mvc\Application->run() /usr/local/vufind/httpd/public/index.php:59
PHP   4. Zend\EventManager\EventManager->trigger() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:313
PHP   5. Zend\EventManager\EventManager->triggerListeners() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207
PHP   6. call_user_func() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP   7. Zend\Mvc\DispatchListener->onDispatch() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP   8. Zend\Mvc\Controller\AbstractController->dispatch() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php:113
PHP   9. Zend\EventManager\EventManager->trigger() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractController.php:116
PHP  10. Zend\EventManager\EventManager->triggerListeners() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207
PHP  11. call_user_func() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP  12. Zend\Mvc\Controller\AbstractActionController->onDispatch() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP  13. VuFindConsole\Controller\UtilController->cssbuilderAction() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php:83
PHP  14. VuFindTheme\LessCompiler->compile() /usr/local/vufind/httpd/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php:553
PHP  15. VuFindTheme\LessCompiler->processTheme() /usr/local/vufind/httpd/module/VuFindTheme/src/VuFindTheme/LessCompiler.php:120
PHP  16. Less_Cache::CleanCache() /usr/local/vufind/httpd/module/VuFindTheme/src/VuFindTheme/LessCompiler.php:148
PHP  17. scandir() /usr/local/vufind/httpd/vendor/oyejorge/less.php/lib/Less/Cache.php:245
PHP Warning:  scandir(): (errno 2): No such file or directory in /usr/local/vufind/httpd/vendor/oyejorge/less.php/lib/Less/Cache.php on line 245
PHP Stack trace:
PHP   1. {main}() /usr/local/vufind/httpd/util/cssBuilder.php:0
PHP   2. require_once() /usr/local/vufind/httpd/util/cssBuilder.php:32
PHP   3. Zend\Mvc\Application->run() /usr/local/vufind/httpd/public/index.php:59
PHP   4. Zend\EventManager\EventManager->trigger() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:313
PHP   5. Zend\EventManager\EventManager->triggerListeners() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207
PHP   6. call_user_func() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP   7. Zend\Mvc\DispatchListener->onDispatch() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP   8. Zend\Mvc\Controller\AbstractController->dispatch() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php:113
PHP   9. Zend\EventManager\EventManager->trigger() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractController.php:116
PHP  10. Zend\EventManager\EventManager->triggerListeners() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:207
PHP  11. call_user_func() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP  12. Zend\Mvc\Controller\AbstractActionController->onDispatch() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php:468
PHP  13. VuFindConsole\Controller\UtilController->cssbuilderAction() /usr/local/vufind/httpd/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php:83
PHP  14. VuFindTheme\LessCompiler->compile() /usr/local/vufind/httpd/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php:553
PHP  15. VuFindTheme\LessCompiler->processTheme() /usr/local/vufind/httpd/module/VuFindTheme/src/VuFindTheme/LessCompiler.php:120
PHP  16. Less_Cache::CleanCache() /usr/local/vufind/httpd/module/VuFindTheme/src/VuFindTheme/LessCompiler.php:148
PHP  17. scandir() /usr/local/vufind/httpd/vendor/oyejorge/less.php/lib/Less/Cache.php:245

Die Ursache dafür verstehe ich noch nicht. Soweit ich https://github.com/vufind-org/vufind/blob/9e3a406c41636e5448c6d97f2aeb53c669a94cdd/vendor/oyejorge/less.php/lib/Less/Cache.php#L245-L246 interpretiere ist das aber nur ein ästhetisches Problem.

marahellstern commented 8 years ago

Die less-Kompilation ist jetzt massiv schneller! Danke!

guenterh commented 8 years ago

Hallo Markus und Mara, ja, das ist doch gut. Ich bin mit der relativ langsamen Komilierung bisher kaum konfrontiert gewesen, da ich das selber bisher selten gemacht habe. Ich habe die Änderungen von Lukas gesehen, aber noch nicht den Hintergrund verstanden. Das denke ich macht aber auch nichts, Hauptsache Mara kann besser arbeiten. Wie wir das später 'rückintegrieren' müssen wir dann schauen Günter

guenterh commented 8 years ago

@ltog Hallo Lukas, ja, der sog. Compilationsprozess wirft Fehlermeldungen, die zum Teil mit permissions zu tun haben. Muss jedoch gestehen, dass mir die Hintergründe dazu bisher zum grossen Teil verschlossen geblieben sind. Habe mal versucht der Sache auf den Grund zu gehen, dies dann aber wieder abgebrochen. Im Moment beachte ich die Meldungen nicht wenn die Comilierung erfolgreich ist. Günter

ltog commented 8 years ago

@guenterh Bist du sicher, dass es Probleme mit den Berechtigungen sind? Bei mir gibt es (wie oben beschrieben)

Im ersten Fall existiert das Verzeichnis tatsächlich nicht, im zweiten Fall vermute ich, dass ein leerer String übergeben wurde.

guenterh commented 8 years ago

@ltog @oschihin @marahellstern
Berechtigungen waren mal ein Problem. Wie schon geschrieben: Ich verstehe auch zu wenig, was im Hintergrund alles passiert und hatte bisher nicht die Zeit, dem im Detail nachzugehen. Die Meldung kommt aus einer Komponente 'oyejorge' - ich nenne sie manchmal 'Freund Jorge' und der Fehler trat bei mir nicht im bootprint3 sondern im theme linkedswissbib auf. Nachdem ich dort das angeforderte Verzeichnis angelegt hatte, erhielt ich den Fehler nicht mehr.

BTW: Die Kompilierung ist nun wirklich rasant schnell! Ich denke das ist für Mara eine gute Verbesserung. Für uns war das bisher wenig relevant, weil wir in der Regel nur bei der Verteilung compilieren und die meisten CSS Anpassungen bisher von unserem Dienstleister snowflake gemacht wurden. Vielleicht wären ihre Leistungen mit schnellerer Kompilierung billiger gewesen....

Lukas: Da Du die Anpassungen in einem script von VFCore gemacht hast, kannst Du ja mal einen Vorschlag auf der VuFind Techliste machen? Günter

ltog commented 8 years ago

@guenterh : Danke für den Vorschlag mit der Mailingliste. Ich habe ein Mail gschrieben: http://sourceforge.net/p/vufind/mailman/message/34332791/

Die Antwort von Demian Katz:

Thanks for sharing this. I'll do some experimentation with it (and consult with Chris, who developed most of the LESS code). As long as we don't find any problems, it should make its way into master soon.

Demian