Angus Leeming wrote: > Alfredo Braunstein wrote: > >> I've tried the previews in xforms and LyX becomes pretty slow when images >> are loading. I've changed the LoaderQueue clock to come back every .5 >> secs intead of .1 secs, and to load 5 images at a time instead of 10. Is >> the xforms graphics loader so much slower? > > Probably. Remember, xforms has been a 'one man band' whereas Qt has a > whole orchestra of players working on it. >
Well, I accused xform unfairly. It seems that my lyx-xforms is using lyxpreview->png->ppm roundtrip for previews, instead of a more direct lyxpreview->ppm. Is it true that the only way to make lyx to prefer the second option is to remove the lyxpreview->png converted definition? Attached is the patch to make possible to change the priority, if you still want to apply it. It is not needed, but is cleaner than hardcoding it. And may be needed for other frontends, who knows. You will need to apply my other mini patch first. If want to apply the second but not the first (still not convinced about that one? It works better for me, and cannot do any harm), then shout and I rediff it. Thanks, Alfredo
Index: frontends/xforms/lyx_gui.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/lyx_gui.C,v retrieving revision 1.32 diff -u -r1.32 lyx_gui.C --- frontends/xforms/lyx_gui.C 2003/02/11 17:53:38 1.32 +++ frontends/xforms/lyx_gui.C 2003/02/22 11:32:48 @@ -23,6 +23,7 @@ #include "lyx_main.h" #include "lyxrc.h" #include "lyxfont.h" +#include "graphics/LoaderQueue.h" // FIXME: move this stuff out again #include "bufferlist.h" @@ -171,6 +172,8 @@ // must do this /before/ lyxrc gets read lyxrc.dpi = getDPI(); + + LoaderQueue::setPriority(10,100); } Index: frontends/xforms/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.673 diff -u -r1.673 ChangeLog --- frontends/xforms/ChangeLog 2003/02/20 22:38:27 1.673 +++ frontends/xforms/ChangeLog 2003/02/22 11:32:56 @@ -1,3 +1,7 @@ +2003-02-22 Alfredo Braunstein <[EMAIL PROTECTED]> + + * lyx_gui.C (parse_init): added a call to LoaderQueue::setPriority + 2003-02-17 John Levon <[EMAIL PROTECTED]> * FormSpellchecker.h: Index: frontends/qt2/lyx_gui.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/lyx_gui.C,v retrieving revision 1.32 diff -u -r1.32 lyx_gui.C --- frontends/qt2/lyx_gui.C 2003/02/13 16:52:53 1.32 +++ frontends/qt2/lyx_gui.C 2003/02/22 11:32:56 @@ -24,6 +24,7 @@ #include "lyxrc.h" #include "lyxfont.h" #include "funcrequest.h" +#include "graphics/LoaderQueue.h" // FIXME: move this stuff out again #include "bufferlist.h" @@ -118,6 +119,8 @@ lyxrc.dpi = getDPI(); initEncodings(); + + LoaderQueue::setPriority(10,100); } Index: frontends/qt2/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.407 diff -u -r1.407 ChangeLog --- frontends/qt2/ChangeLog 2003/02/17 18:40:03 1.407 +++ frontends/qt2/ChangeLog 2003/02/22 11:32:59 @@ -1,3 +1,7 @@ +2003-02-22 Alfredo Braunstein <[EMAIL PROTECTED]> + + * lyx_gui.C (parse_init): added a call to LoaderQueue::setPriority + 2003-02-17 John Levon <[EMAIL PROTECTED]> * QSpellchecker.h: Index: graphics/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/graphics/ChangeLog,v retrieving revision 1.140 diff -u -r1.140 ChangeLog --- graphics/ChangeLog 2003/02/21 10:04:08 1.140 +++ graphics/ChangeLog 2003/02/22 11:33:01 @@ -1,3 +1,12 @@ +2003-02-22 Alfredo Braunstein <[EMAIL PROTECTED]> + + * LoaderQueue.[Ch] (setPriority): added + +2003-02-21 Alfredo Braunstein <[EMAIL PROTECTED]> + + * PreviewLoader.C (finishedGenerating): reversed the loading order so + first images get 'touched' last, and so load first. + 2003-02-20 Alfredo Braunstein <[EMAIL PROTECTED]> * LoaderQueue.[Ch]: added. Implements a service queue that loads Index: graphics/LoaderQueue.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/graphics/LoaderQueue.C,v retrieving revision 1.1 diff -u -r1.1 LoaderQueue.C --- graphics/LoaderQueue.C 2003/02/21 10:04:08 1.1 +++ graphics/LoaderQueue.C 2003/02/22 11:33:01 @@ -20,6 +20,8 @@ namespace grfx { +int LoaderQueue::s_numimages_ = 5; +int LoaderQueue::s_millisecs_ = 500; LoaderQueue & LoaderQueue::get() { @@ -34,7 +36,7 @@ lyxerr[Debug::GRAPHICS] << "LoaderQueue: " << cache_queue_.size() << " items in the queue" << endl; - int counter = 10; + int counter = s_numimages_; while (cache_queue_.size() && counter--) { if(cache_queue_.front()->status() == WaitingToLoad) cache_queue_.front()->startLoading(); @@ -49,7 +51,18 @@ } -LoaderQueue::LoaderQueue() : timer(100, Timeout::ONETIME), +void LoaderQueue::setPriority(int numimages , int millisecs) +{ + s_numimages_ = numimages; + s_millisecs_ = millisecs; + lyxerr[Debug::GRAPHICS] << "LoaderQueue: priority set to " + << s_numimages_ << " images at a time, " + << s_millisecs_ << " milliseconds between calls" + << endl; +} + + +LoaderQueue::LoaderQueue() : timer(s_millisecs_, Timeout::ONETIME), running_(false) { timer.timeout.connect(boost::bind(&LoaderQueue::loadNext, this)); @@ -71,6 +84,7 @@ { lyxerr[Debug::GRAPHICS] << "LoaderQueue: waking up" << endl; running_ = true ; + timer.setTimeout(s_millisecs_); timer.start(); } Index: graphics/LoaderQueue.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/graphics/LoaderQueue.h,v retrieving revision 1.1 diff -u -r1.1 LoaderQueue.h --- graphics/LoaderQueue.h 2003/02/21 10:04:08 1.1 +++ graphics/LoaderQueue.h 2003/02/22 11:33:01 @@ -33,34 +33,45 @@ class LoaderQueue { public: - //use this to request a loading + ///use this to request a loading void touch(Cache::ItemPtr const & item); - //query if the clock is ticking + ///query if the clock is ticking bool running() const; - //get the and only instance of the class + ///get the and only instance of the class static LoaderQueue & get(); + /**adjusts the queue priority: numimages is the number of images + loaded in every clock tick, millisecs the time interval between + these ticks. Higher numimages, lower millisecs means higher + priority. + */ + static void setPriority(int numimages , int millisecs); private: - //this class is a singleton class... use LoaderQueue::get() instead + ///this class is a singleton class... use LoaderQueue::get() instead LoaderQueue(); - //in-progress loading queue (elements are unique here) + ///in-progress loading queue (elements are unique here) std::list<Cache::ItemPtr> cache_queue_; - //makes faster the insertion of new elements + ///makes faster the insertion of new elements std::set<Cache::ItemPtr> cache_set_; - //newly touched element go here, loadNext move them to cache_queue_ + ///newly touched element go here, loadNext move them to cache_queue_ std::queue<Cache::ItemPtr> bucket_; - // + /// Timeout timer; - // + /// bool running_; - //moves bucket_ to cache_queue_ + /// + static int s_numimages_ ; + /// + static int s_millisecs_ ; + + ///moves bucket_ to cache_queue_ void emptyBucket(); - //adds or reprioritizes one element in cache_queue_ + ///adds or reprioritizes one element in cache_queue_ void addToQueue(Cache::ItemPtr const & item); - //this is the 'threaded' method, that does the loading in background + ///this is the 'threaded' method, that does the loading in background void loadNext(); - // + /// void startLoader(); - // + /// void stopLoader(); };