joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Investigate if mutex can be removed when saving a note

Open laurent22 opened this issue 6 months ago • 0 comments

Operating system

Android

Joplin version

2.13

Desktop version info

No response

Current behaviour

When a note is saved a good part of the time is spent waiting for this mutex:

https://github.com/laurent22/joplin/blob/d02058d3372867ef879d7026035c031a7369b787/packages/lib/database.ts#L200

It's particularly noticeable during sync when many notes are being saved, so if we optimise this it will make sync faster.

However it's not clear why this mutex was added there since in theory SQLite should already ensure that only one transaction runs at a time, and would do so in a more efficient way.

We should investigate whether we can switch to a native transaction.

It applies to all platforms but we should start our tests with mobile because if we can't get it to work with this, it doesn't matter if we make it work in desktop (should be easier on desktop). It's also more important to optimise for mobile.

One issue with rn-sqlite is that transactions don't rollback on failure or at least not by default so that will need to be solved first: https://github.com/andpor/react-native-sqlite-storage/issues/566

Finally, to check if it's a useful change, we should create an on-device benchmark.

Expected behaviour

No response

Logs

No response

laurent22 avatar Jan 04 '24 10:01 laurent22