-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TrackCache: Fixes and optimizations (lp1738253/17382271738028) #1415
TrackCache: Fixes and optimizations (lp1738253/17382271738028) #1415
Conversation
@Be-ing Do you have a log excerpt for me? I'm using exactly this combination for tests. |
I can't tell at first glance where anything is going wrong, so here is the whole log:
|
@Be-ing I don't have any recordings, so I'll check that! |
Backtrace:
|
...this conditional behavior has been lost when removing the recent tracks cache from TrackDAO.
...that is triggered when switching between browse views
Yes, the hanging on startup is solved. |
@Be-ing The last commit might fix the hang on startup. |
Yes, that is fixed. Analysis is still broken. |
...to reduce lock contention and keep the UI responsive
Done. I've reduced lock contention on TrackCache as much as possible. We even found and fixed a serious bug of the initialization order on startup! Remaining open issues with the (batch) analysis of tracks do not directly affect the track cache and will be solved separately. |
We should include this in the first beta, because I fear that the initialization order bug might cause subsequent freezes or crashes. |
Unfortunately this is not reviewed ans so doe not meet our quality standard. |
A BIG thanks to @uklotzde for spending so much time into this lately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I am done with the post merge review now.
I have added some questions and I am unsure about invalid tracks. I would be nice if we can clarify this.
if (!pTrack) { | ||
qWarning() << "Skipping inaccessible file" | ||
<< filepath; | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original we skip inaccessible files here. Do you have an idea, when it happens?
Do we now have inaccessible files in the results?
m_dirtyTracks.remove(trackId); | ||
return TrackPointer(); | ||
TrackPointer pTrack; | ||
if (m_bIsCaching) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct that this is true for Mixxx tracks only, but not for third party libraries?
Why? It looks like they have their own instance of BaseTrackCache. Is there his kind of legacy?
Can we either unify this to only one instance or inherit form BaseTracKCache as a base class?
I am not sure what makes actually sense here.
|
||
// Import metadata from file | ||
TrackPointer pTrack = | ||
TrackCache::instance().resolve( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseTrackCache uses TrackCache this sounds like swapped class named from legacy.
@@ -202,6 +204,18 @@ void TrackDAO::saveTrack(Track* pTrack) { | |||
SoundSourceProxy::exportTrackMetadataBeforeSaving(pTrack); | |||
} | |||
|
|||
// The track cache can safely be unlocked now that the metadata has | |||
// been exported to the file. Updating the database is thread-safe | |||
// an we accept this very small chance of a race condition here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A race condition between what? What can happen at worse?
By removing the recent tracks cache from TrackDAO the new TrackCache has now become the central authority for accessing track objects. I didn't notice that lock contention was much too high in some uses cases. Now time spans during which TrackCache is locked should be much shorter!
The most time consuming operation is when entries are evicted and the cache must be kept locked while both updating the database and exporting metadata for safety reasons. I will try to extract the database update from the lock scope, but this might not be possible with the current architecture that closely couples the database and UI layers. Please test if enabling export of track metadata makes a difference for you. I am running my tests at
1011.6 ms latency with metadata export enabled anddidn't notice any drop outs so fardropouts still occur. But these dropouts also occur with older versions where the TrackCache & Export stuff has not been merged. I'm still trying to find out where this regression started.I even discovered a serious bug in TrackCache after changing the access pattern in the browse view. It was caused by a strayed line of code that may have survived a previous merge. Luckily the multitude of debug assertions with consistency checks revealed this bug instantly.
Please note that the "sluggish" response during batch analysis is still not fixed, although it might also profit from these changes.