Another issue like the one we had with the 2.3.1 release, related to the
fix for #9158. The commit message explains the issue. The fix seems to
me to make sense anyway.

The second patch also seems to me to make sense, and it ought to prevent
these kinds of issues arising in future. But maybe it's a bit heavy handed?

Comments welcome.

My plan is to go ahead and release 2.3.2 for non-Windows platforms as
planned, as this issue does not seem to affect them. If this fix seems
right, then I'll bulid a new Windows installer for testing and, if that
works, then I'll release a 2.3.2-1 tarball and a Windows installer built
on it as soon as I'm able.

Comments welcome on that, too.

Riki


>From f7cb4d9500057e5b818e86774a6b463deccd32ff Mon Sep 17 00:00:00 2001
From: Richard Kimberly Heck <[email protected]>
Date: Wed, 12 Dec 2018 01:18:16 -0500
Subject: [PATCH] Fix slowness problem reported on the mailing list on Windows.

https://marc.info/?l=lyx-devel&m=154458979925296&w=2

This is related to the fix for #9158 and the caching of bibfile
information. On Windows, it is incredibly slow to run kpsewhich,
which we do to check where files actually are, so as to get info
about them (e.g., timestamps). So we have started to cache that
as a map. The map is supposed to be invalidated when various
things happen, but an oversight was causing it to be invalidated
on every cut operation. This is because cutting uses a temporary
Buffer, and the operations on it were affecting the *global* cache
of biblio file info. (It makes sense to have a global cache, since
these files are not document-specific.) Basically, we have to update
the list of bibfiles in that temporary Buffer---but that is one of
the things that invalidated the cache. The solution is only to
invalidate the cache if the list of bibfiles has actually changed
(a sensible idea anyway). The only time that will happen in the
temporary Buffer is when the copied information contains a BibTeX
inset. That should be fairly rare.
---
 src/Buffer.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index e572fb30a8..b71c3fcd83 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2334,6 +2334,7 @@ void Buffer::updateBibfilesCache(UpdateScope scope) const
 		return;
 	}
 
+	docstring_list old_cache = d->bibfiles_cache_;
 	d->bibfiles_cache_.clear();
 	for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
 		if (it->lyxCode() == BIBTEX_CODE) {
@@ -2357,8 +2358,9 @@ void Buffer::updateBibfilesCache(UpdateScope scope) const
 		}
 	}
 	d->bibfile_cache_valid_ = true;
-	d->bibinfo_cache_valid_ = false;
 	d->cite_labels_valid_ = false;
+	if (d->bibfiles_cache_ != old_cache)
+		d->bibinfo_cache_valid_ = false;
 }
 
 
@@ -2455,6 +2457,9 @@ void Buffer::checkIfBibInfoCacheIsValid() const
 		return;
 	}
 
+	// we'll assume it's ok and change this if it's not
+	d->bibinfo_cache_valid_ = true;
+	d->cite_labels_valid_ = true;
 	// compare the cached timestamps with the actual ones.
 	docstring_list const & bibfiles_cache = getBibfiles();
 	for (auto const & bf : bibfiles_cache) {
@@ -2488,6 +2493,7 @@ void Buffer::reloadBibInfoCache() const
 	checkIfBibInfoCacheIsValid();
 	if (d->bibinfo_cache_valid_)
 		return;
+	LYXERR(Debug::FILES, "Bibinfo cache was invalid.");
 
 	// re-read file locations when this info changes
 	// FIXME Is this sufficient? Or should we also force that
-- 
2.17.2

Reply via email to