Before opening a new bug report, please search the forum for duplicates and follow the Troubleshooting Guide.
Steps to reproduce
- Have a large vault (50k notes) with many links between them
- Rename some note that has some backlinks
Did you follow the troubleshooting guide? [Y/N]
Y
Expected result
No lags
Actual result
Huge UI lag during the link update (5+ s)
Environment
SYSTEM INFO:
Obsidian version: v1.4.16
Installer version: v1.4.13
Operating system: Windows 10 Pro 10.0.22621
Login status: logged in
Catalyst license: insider
Insider build toggle: on
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on
RECOMMENDATIONS:
none
Additional information
During my performance investigation, I found the bottleneck in the app.metadataCache._getLinkpathDest
function called many times from runAsyncLinkUpdate
I made the following fix that heavily improves the performance
const _getLinkpathDestOriginal = app.metadataCache._getLinkpathDest;
const resultCache = new Map();
app.metadataCache._getLinkpathDest = function(origin, path) {
const key = `${origin}|${path}`;
let result;
if (resultCache.has(key)) {
result = resultCache.get(key);
result = result.filter(f => !f.deleted);
if (result.length > 0) {
return result;
}
}
result = _getLinkpathDestOriginal.call(this, origin, path);
resultCache.set(key, result);
return result;
};
As I am using only markdown links with relative path, I think my implementation is quite safe to use. Not sure if it is reliable for Wikilinks usecases.