[PATCH] Re: DepTable patch for 1.2cvs
Ben Stanley wrote: I have now written something for 1.2 which keeps only one mtime; I'd better test before posting.
[PATCH] Re: DepTable patch for 1.2cvs
Ben Stanley wrote: I have now written something for 1.2 which keeps only one mtime; I'd better test before posting. Dammit I'd better hit the attach button instead of the send button... Anyway, this patch corrects and tidies up the mtime stuff. Ben. --- lyx-devel-orig/src/ChangeLogWed Dec 12 09:26:32 2001 +++ lyx-devel/src/ChangeLog Wed Dec 12 09:24:51 2001 @@ -1,3 +1,9 @@ +2001-12-12 Ben Stanley [EMAIL PROTECTED] + + * DepTable.h + * DepTable.C: Implement mtime checking to reduce time + spent doing CRCs. + 2001-12-10 Jean-Marc Lasgouttes [EMAIL PROTECTED] * tabular-old.C (getTokenValue): --- lyx-devel-orig/src/DepTable.h Tue Nov 27 13:56:55 2001 +++ lyx-devel/src/DepTable.hFri Dec 7 13:01:06 2001 @@ -8,6 +8,7 @@ * * This file is Copyright 1996-2001 * Lars Gullik Bjønnes + * Ben Stanley * * == */ @@ -29,9 +30,7 @@ filename. Should we insert files with .sty .cls etc as extension? */ void insert(string const f, - bool upd = false, - unsigned long one = 0, - unsigned long two = 0); + bool upd = false); /// void update(); @@ -47,14 +46,23 @@ bool extchanged(string const ext) const; /// bool exist(string const fil) const; + /// returns true if any files with ext exist + bool ext_exist(string const ext) const; /// void remove_files_with_extension(string const ); + /// + void remove_file(string const ); private: /// struct dep_info { - unsigned long first; - unsigned long second; - long mtime; + /// Previously calculated CRC value + unsigned long crc_prev; + /// Current CRC value - only re-computed if mtime has changed. + unsigned long crc_cur; + /// mtime from last time current CRC was calculated. + long mtime_cur; + /// + bool changed() const; }; /// typedef std::mapstring, dep_info DepList; @@ -63,3 +71,4 @@ }; #endif + --- lyx-devel-orig/src/DepTable.C Thu Dec 6 10:57:59 2001 +++ lyx-devel/src/DepTable.CWed Dec 12 08:31:26 2001 @@ -7,6 +7,7 @@ * * This file is Copyright 1996-2001 * Lars Gullik Bjønnes + * Ben Stanley * * == */ @@ -35,69 +36,78 @@ using std::ifstream; using std::endl; +inline bool DepTable::dep_info::changed() const +{ + return crc_prev != crc_cur crc_cur != 0; +} + void DepTable::insert(string const fi, - bool upd, - unsigned long one, - unsigned long two) + bool upd) { // not quite sure if this is the correct place for MakeAbsPath string f = MakeAbsPath(fi); if (deplist.find(f) == deplist.end()) { - long mtime = 0; + dep_info di; + di.crc_prev = 0; if (upd) { - one = two; - two = lyx::sum(f); + lyxerr[Debug::DEPEND] CRC... flush; + di.crc_cur = lyx::sum(f); + lyxerr[Debug::DEPEND] done. endl; struct stat f_info; stat(fi.c_str(), f_info); - mtime = f_info.st_mtime; + di.mtime_cur = f_info.st_mtime; + } else { + di.crc_cur = 0; + di.mtime_cur = 0; } - dep_info di; - di.first = one; - di.second = two; - di.mtime = mtime; -#if 0 - deplist[f] = make_pair(one, two); -#else deplist[f] = di; -#endif + } else { + lyxerr[Debug::DEPEND] Already in DepTable endl; } } void DepTable::update() { - for (DepList::iterator itr = deplist.begin(); - itr != deplist.end(); - ++itr) { - unsigned long const one = itr-second.second; - unsigned long two = one; - long mtime = itr-second.mtime; - struct stat f_info; - stat(itr-first.c_str(), f_info); + lyxerr[Debug::DEPEND] Updating DepTable... endl; + time_t start_time = time(0); - if (mtime != f_info.st_mtime) { - two = lyx::sum(itr-first); - mtime = f_info.st_mtime; + DepList::iterator itr = deplist.begin(); + while (itr != deplist.end()) { + dep_info di = itr-second; + + struct stat f_info; + if (0 ==
[PATCH] Re: DepTable patch for 1.2cvs
Ben Stanley wrote: > I have now written something for 1.2 which keeps only one mtime; I'd > better test before posting.
[PATCH] Re: DepTable patch for 1.2cvs
Ben Stanley wrote: > I have now written something for 1.2 which keeps only one mtime; I'd > better test before posting. Dammit I'd better hit the attach button instead of the send button... Anyway, this patch corrects and tidies up the mtime stuff. Ben. --- lyx-devel-orig/src/ChangeLogWed Dec 12 09:26:32 2001 +++ lyx-devel/src/ChangeLog Wed Dec 12 09:24:51 2001 @@ -1,3 +1,9 @@ +2001-12-12 Ben Stanley <[EMAIL PROTECTED]> + + * DepTable.h + * DepTable.C: Implement mtime checking to reduce time + spent doing CRCs. + 2001-12-10 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * tabular-old.C (getTokenValue): --- lyx-devel-orig/src/DepTable.h Tue Nov 27 13:56:55 2001 +++ lyx-devel/src/DepTable.hFri Dec 7 13:01:06 2001 @@ -8,6 +8,7 @@ * * This file is Copyright 1996-2001 * Lars Gullik Bjønnes + * Ben Stanley * * == */ @@ -29,9 +30,7 @@ filename. Should we insert files with .sty .cls etc as extension? */ void insert(string const & f, - bool upd = false, - unsigned long one = 0, - unsigned long two = 0); + bool upd = false); /// void update(); @@ -47,14 +46,23 @@ bool extchanged(string const & ext) const; /// bool exist(string const & fil) const; + /// returns true if any files with ext exist + bool ext_exist(string const& ext) const; /// void remove_files_with_extension(string const &); + /// + void remove_file(string const &); private: /// struct dep_info { - unsigned long first; - unsigned long second; - long mtime; + /// Previously calculated CRC value + unsigned long crc_prev; + /// Current CRC value - only re-computed if mtime has changed. + unsigned long crc_cur; + /// mtime from last time current CRC was calculated. + long mtime_cur; + /// + bool changed() const; }; /// typedef std::mapDepList; @@ -63,3 +71,4 @@ }; #endif + --- lyx-devel-orig/src/DepTable.C Thu Dec 6 10:57:59 2001 +++ lyx-devel/src/DepTable.CWed Dec 12 08:31:26 2001 @@ -7,6 +7,7 @@ * * This file is Copyright 1996-2001 * Lars Gullik Bjønnes + * Ben Stanley * * == */ @@ -35,69 +36,78 @@ using std::ifstream; using std::endl; +inline bool DepTable::dep_info::changed() const +{ + return crc_prev != crc_cur && crc_cur != 0; +} + void DepTable::insert(string const & fi, - bool upd, - unsigned long one, - unsigned long two) + bool upd) { // not quite sure if this is the correct place for MakeAbsPath string f = MakeAbsPath(fi); if (deplist.find(f) == deplist.end()) { - long mtime = 0; + dep_info di; + di.crc_prev = 0; if (upd) { - one = two; - two = lyx::sum(f); + lyxerr[Debug::DEPEND] << " CRC..." << flush; + di.crc_cur = lyx::sum(f); + lyxerr[Debug::DEPEND] << "done." << endl; struct stat f_info; stat(fi.c_str(), _info); - mtime = f_info.st_mtime; + di.mtime_cur = f_info.st_mtime; + } else { + di.crc_cur = 0; + di.mtime_cur = 0; } - dep_info di; - di.first = one; - di.second = two; - di.mtime = mtime; -#if 0 - deplist[f] = make_pair(one, two); -#else deplist[f] = di; -#endif + } else { + lyxerr[Debug::DEPEND] << " Already in DepTable" << endl; } } void DepTable::update() { - for (DepList::iterator itr = deplist.begin(); - itr != deplist.end(); - ++itr) { - unsigned long const one = itr->second.second; - unsigned long two = one; - long mtime = itr->second.mtime; - struct stat f_info; - stat(itr->first.c_str(), _info); + lyxerr[Debug::DEPEND] << "Updating DepTable..." << endl; + time_t start_time = time(0); - if (mtime != f_info.st_mtime) { - two = lyx::sum(itr->first); - mtime = f_info.st_mtime; + DepList::iterator itr = deplist.begin(); + while (itr != deplist.end()) { + dep_info = itr->second; + +
DepTable patch for 1.2cvs
Lars Gullik Bjønnes wrote: Ben Stanley [EMAIL PROTECTED] writes: | I still need to get the proper DepTable patch out. The patch that is | currently in 1.2 is b0rken. explain. Hmmm... I have a new implementation which keeps an old and a new mtime, and checks that before checking the old and new crcs (and possibly re-calculating crcs)... but now that I think about it again, I shouldn't need to keep two mtimes. However, the version currently in 1.2 writes the 3 numbers to the deptable, which is incompatible with previous behaviour which writes/reads only 2. This needs to be fixed at the very least - my new patch stores only 2 and 'does the right thing' when presented with an old file, and causes the old implementation to DTRT when presented with a new style file. And the version in 1.2 doesn't behave correctly when it finds a file who's mtime has changed. It doesn't shuffle the crc value from second to first before overwriting it with the new value (in update()). This causes excessive LaTeX runs. I have now written something for 1.2 which keeps only one mtime; I'd better test before posting. Ben
Re: DepTable patch for 1.2cvs
On Fri, Dec 07, 2001 at 01:29:15AM +0100, Lars Gullik Bjønnes wrote: Ben Stanley [EMAIL PROTECTED] writes: | However, the version currently in 1.2 writes the 3 numbers to the | deptable, which is incompatible with previous behaviour which | writes/reads only 2. No, we do not have to do that. Everything in LyX is written to work with USE_TEMPDIR=true, if you don't use that expect strange behaviour. so, why have we got the option again ?? DTRT? do the right thing ... as in the spike lee film ... john -- Faced with the prospect of rereading this book, I would rather have my brains ripped out by a plastic fork. - Charles Cooper on Business at the Speed of Thought
Re: DepTable patch for 1.2cvs
Lars Gullik Bjønnes wrote: Ben Stanley [EMAIL PROTECTED] writes: | However, the version currently in 1.2 writes the 3 numbers to the | deptable, which is incompatible with previous behaviour which | writes/reads only 2. No, we do not have to do that. Everything in LyX is written to work with USE_TEMPDIR=true, if you don't use that expect strange behaviour. Also I do not think that we have to be deptable compatible with 1.1.6 (and older 1.1.2CVS does not matter). Anyway, my current patch is backwards compatible - reads/writes 2 values, and Does The Right Thing with old/new files, even if it causes CRCs to be calculated when not strictly necessary in the case that you changed LyX version and didn't use a tmp dir. This behaviour came about without writing extra code ie for free :-). Ben.
Re: DepTable patch for 1.2cvs
On Fri, Dec 07, 2001 at 01:42:41AM +0100, Lars Gullik Bjønnes wrote: Everything in LyX is written to work with USE_TEMPDIR=true, if you don't use that expect strange behaviour. | so, why have we got the option again ?? Do I have to say it again? I suppose not ... archives are there for a reason ... DTRT? | do the right thing ... as in the spike lee film ... ok... I usualy use DIR ... now you have to tell us what that stands for and what it means ;) john -- Faced with the prospect of rereading this book, I would rather have my brains ripped out by a plastic fork. - Charles Cooper on Business at the Speed of Thought
DepTable patch for 1.2cvs
Lars Gullik Bjønnes wrote: >Ben Stanley <[EMAIL PROTECTED]> writes: > >| I still need to get the proper DepTable patch out. The patch that is >| currently in 1.2 is b0rken. > >explain. > Hmmm... I have a new implementation which keeps an old and a new mtime, and checks that before checking the old and new crcs (and possibly re-calculating crcs)... but now that I think about it again, I shouldn't need to keep two mtimes. However, the version currently in 1.2 writes the 3 numbers to the deptable, which is incompatible with previous behaviour which writes/reads only 2. This needs to be fixed at the very least - my new patch stores only 2 and 'does the right thing' when presented with an old file, and causes the old implementation to DTRT when presented with a new style file. And the version in 1.2 doesn't behave correctly when it finds a file who's mtime has changed. It doesn't shuffle the crc value from second to first before overwriting it with the new value (in update()). This causes excessive LaTeX runs. I have now written something for 1.2 which keeps only one mtime; I'd better test before posting. Ben
Re: DepTable patch for 1.2cvs
On Fri, Dec 07, 2001 at 01:29:15AM +0100, Lars Gullik Bjønnes wrote: > Ben Stanley <[EMAIL PROTECTED]> writes: > > | However, the version currently in 1.2 writes the 3 numbers to the > | deptable, which is incompatible with previous behaviour which > | writes/reads only 2. > > No, we do not have to do that. > Everything in LyX is written to work with USE_TEMPDIR=true, if you > don't use that expect strange behaviour. so, why have we got the option again ?? > DTRT? do the right thing ... as in the spike lee film ... john -- "Faced with the prospect of rereading this book, I would rather have my brains ripped out by a plastic fork." - Charles Cooper on "Business at the Speed of Thought"
Re: DepTable patch for 1.2cvs
Lars Gullik Bjønnes wrote: >Ben Stanley <[EMAIL PROTECTED]> writes: > >| However, the version currently in 1.2 writes the 3 numbers to the >| deptable, which is incompatible with previous behaviour which >| writes/reads only 2. > >No, we do not have to do that. >Everything in LyX is written to work with USE_TEMPDIR=true, if you >don't use that expect strange behaviour. > >Also I do not think that we have to be deptable compatible with 1.1.6 > (and older 1.1.2CVS does not matter). > Anyway, my current patch is backwards compatible - reads/writes 2 values, and Does The Right Thing with old/new files, even if it causes CRCs to be calculated when not strictly necessary in the case that you changed LyX version and didn't use a tmp dir. This behaviour came about without writing extra code ie for free :-). Ben.
Re: DepTable patch for 1.2cvs
On Fri, Dec 07, 2001 at 01:42:41AM +0100, Lars Gullik Bjønnes wrote: > >> Everything in LyX is written to work with USE_TEMPDIR=true, if you > >> don't use that expect strange behaviour. > > > | so, why have we got the option again ?? > > Do I have to say it again? I suppose not ... archives are there for a reason ... > >> DTRT? > > > | do the right thing ... as in the spike lee film ... > > ok... I usualy use "DIR" ... now you have to tell us what that stands for and what it means ;) john -- "Faced with the prospect of rereading this book, I would rather have my brains ripped out by a plastic fork." - Charles Cooper on "Business at the Speed of Thought"