Comment 11 for bug 905669

Revision history for this message
Ben Clark (bencoder) wrote :

Yes that is what I had determined, that taking the modified time into account was not necessary and in fact could only slow things down. However, since the original bug was that the library rescan is slower than it should be I've been investigating where that can be improved.

The primary delay in rescanning when there have been no changes is where we are marking as verified the existing directory and tracks in these two calls:

m_libraryHashDao.updateDirectoryStatus(dirPath, false, true);
m_trackDao.markTracksInDirectoryAsVerified(dirPath);

on my machine these calls take about 100ms each. I believe this is primarily due to the disk writes, and not due to Indexes or preparing the queries (I investigated both pre-preparing the queries instead of preparing them on demand and adding an index on track_locations.directory, both of which had very little effect [LibraryHashes.directory_path is a PK so is already indexed])

A very simple method to significantly improve the speed is to wrap these two calls in a transaction, that causes us to do just a single write instead of two, speeding up my own rescan by more than a third from 95s to 60s. I've attached the small patch for this.