Open cmcnicholas opened 4 years ago
Updated table with results when no indices are specified, why are indices in the .Net library so much less expensive than realm-js?
Thanks for reporting this @cmcnicholas - we need to investigate this further. There has recently been reported other performance related issues, you're probably experiencing the same regression. Have you tried running the benchmark with other versions of Realm JS? For example version 3?
Thanks for reporting this @cmcnicholas - we need to investigate this further. There has recently been reported other performance related issues, you're probably experiencing the same regression. Have you tried running the benchmark with other versions of Realm JS? For example version 3?
unfortunately the window I had for testing Realm JS and .Net for our use case is over and due to the large number of records we have meant we ended up going with a Xamarin based solution.
@kraenhansen
I've been having the same issues with very poor performance on a large number of insertions (~5K). It takes around 30s-60s for the insertions to complete, even in Release mode, sometimes even more. While with Realm v3 it takes ~2s.
is it true that Realm v3 is faster?!
Yes, totally! I've tried v6 for a couple of releases, then v10, but ultimately switched to v3.6 as it's the only version that's consistent enough (had a few crashes on both v6 and v10 that never happen on v3).
@noldidrita Which was the last version you tried with? We did fix and shipped a performance regression. So if you notice any other major regressions, we would love to hear about them!
@noldidrita thank you! but I decided to get realm out of the project. waste so much time with this.
These tests are a bit outdated, seeing as they were done with realm@4.0.0-beta.0
. I re-ran the supplied sample-code with realm@10.0.0-rc.1
& realm@3.6.5
on iOS Simulator & an Android emulator.
(simulator/emulator benchmarks are not ideal, but perhaps ok for comparison in this case)
realm@10.0.0-rc.1
:(similar times found with realm@6.1.4 ) |
Test | 1k inserts | 10k inserts | 100k inserts |
---|---|---|---|---|
realm-js iOS | 144ms | 777ms | 7.36s | |
realm-js Android | 201ms | 1.65s | 18.03s |
realm@3.6.5
:(for comparison) | Test | 1k inserts | 10k inserts | 100k inserts |
---|---|---|---|---|
realm-js iOS | 240ms | 884ms | 6.04s | |
realm-js Android | 148ms | 881ms | 7.52s |
We'll leave the issue open, primarily with focus on Android, which seems to be lacking a bit behind.
Yes, totally! I've tried v6 for a couple of releases, then v10, but ultimately switched to v3.6 as it's the only version that's consistent enough (had a few crashes on both v6 and v10 that never happen on v3).
I tried to downgrade to 3.6 but I'm unable to install Realm with node 15. What node version you guys had to use?
I tried to downgrade to 3.6 but I'm unable to install Realm with node 15. What node version you guys had to use?
@FSPinho node@10
any update on this? facing same issue, finally reverted it back to v3.6.0. AsyncStorage seems faster than realm v6.1.5 & v10.0.1 😅😅
I fixed it without downgrade by doing the following:
Now I'm getting good times for realm@10!
@FSPinho Thank you for your real-world tips!!
@vikas-singh-fareye If possible, it would be very interesting if you can share some code which we can profile to find the bottlenecks.
const schemaVersion = 110;
const schema = [Table1.schema, Table2.schema,.....TableX.schema];
var encryptionKey = new Int8Array(64);
let realm = new Realm({
schemaVersion,
schema,
encryptionKey,
shouldCompactOnLaunch: (totalBytes,usedBytes)=>{
return true
}
});
// Generic method to save multiple realm records
export function saveList(tableName, array, update = true) {
return realm.write(() => {
array.forEach(data => realm.create(tableName, data, update));
});
}
I just updated realm from v3.6.0 to v6.1.5, nothing else has been changed and noticed this slowness issue, then upgraded it to v10.0.1 though there wasn't anything related to it in the v10 change log and issue still persists in both debug and release mode. So finally reverted it back to 3.6.0.
➤ Finn Andersen commented:
Confirmed: performance regression for string based primary keys.
Hi @kneth,
Did you make any progress on this? We were forced to find an alternative solution because of this performance issue back in 2020 and I was wondering if it has been resolved so we can try it out again.
@jaltin Only for string based primary keys (fix released in v10.5.0).
@jaltin Only for string based primary keys (fix released in v10.5.0).
Thanks for quick reply. I will try to test it out.
Also, do you have any idea if it will be addressed further (and if so when) for other types of keys?
I'm also having this same issue. I have inserted around 50K documents into my local realm db, and afterwards when trying to insert more, I run into significant performance degradation. My write speeds on first insertion are averaging around 20-30 documents per second, but once I reach 50K+ (realm db size is 11.6MB), my write speeds slow down to 2-3 writes per second. Reads and queries are also significantly slowed down.
When I delete a large portion of the documents out of the RealmDB, my R/W speeds return back to normal.
Have you discovered a potential cause for the slowdown when RealmDB begins to have large numbers of documents? My product is still in beta, and in production my db could have millions of documents.
Goals
I am trying to understand why the performance of inserts is so poor from a react native environment vs xamarin (using the Realm .Net library).
My use case is initial syncing a mobile application with a backend of items (things like street data, assets, jobs etc.) that can range from 10-500k records for use offline over the period of a week to later be synced back on completion.
The .Net library appears to be orders of magnitude faster and has a more linear timing curve for large inserts, realm-js inserts degrade over time given my tests.
Expected Results
I am expecting similar performance on inserting many records in the realm-js library as it is in the .Net library.
Actual Results
Steps to Reproduce
Attempt to insert a large number of records into a realm.
Code Sample
The following should be copy-pasteable into a brand new react-native app with typescript as the
App.ts
file. Alternatively theonPress
function and models at the end of the code snippet should be all that's necessary.The .Net code is almost like for like.
Version of Realm and Tooling
^4.0.0-beta.0