-
Notifications
You must be signed in to change notification settings - Fork 576
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
Slow performance on writing multiple objects at a time #2989
Comments
there is some known performance issues while in the debug mode , refer to #491 & https://github.com/realm/realm-js#issues-with-debugging for more details. @MD3XTER did you check the same in the production mode? does that have the same performance problem? for benchmarking multiple writes, have a look at the sample given by @bmunkholm at #2154 (comment) , const Realm = require('realm')
Realm.open({
schema: [{
name: 'Page',
properties: {
id: 'int'
}
}]
}).then(realm => {
console.time('nothing')
console.timeEnd('nothing')
console.time('warmup')
realm.write(() => {
for (let i = 0; i < 10; i++) {
realm.create('Page', {id: 5})
}
})
console.timeEnd('warmup')
for (let objects=0; objects<=1000; objects+=100) {
let test = 'Objects ' + objects
console.time(test)
realm.write(() => {
for (let i = 0; i < 100; i++) {
realm.create('Page', {id: 5})
}
});
console.timeEnd(test)
}
process.exit()
}); |
@vazra thank you for your quick reply. I am not using a debugger. I use Reactotron which could make realm-js slow. I have tested the app in production mode. How can I do this benchmark test in production mode? The code that you have attached above is using console.time function. How can I see this in production? |
@MD3XTER try logging to console w/o Reactotron, and check if it's different. By production I mean, not in the development mode, I don't think there's something blocking you from printing to console in non-dev mode. can you clarify? |
@vazra Same issue. On app install, I load a significant amount of data from a static json file into the realm database. Using version 4.0.0-beta.0 this data loads in a few seconds, using 6.0.0 the same load can take up to 10 minutes. Tests are run in production. Within a single write, I loop through the json file and load the database. |
@jimsideout It shouldn't be that slow, what kind of data are you inserting? can you update with a reproducible sample. I ran the above code in realm 5 and 6 , the results are With Realm 5.0.5 (with Node 12 , MacBook Pro)
With Realm 6.0.2 (with Node 12 , MacBook Pro)
|
@jimsideout @MD3XTER In case, if you are working with electron, have a look at the Realm part of Electron React NativeDBs demo available at https://github.com/vazra/electron-react-ts-rxdb-realm-sqlite , in which you can add as much as dummy data and check the performance. |
@vazra looks like the same issue as https://github.com/realm/realm-js/issues/2845 The problem is when creating an object with nested objects. My data is just JSON data that is being looped through. Nothing special, just objects containing about 40 values of strings, ints, bools, and 2 references to other objects. |
Ok. Looks like your issue is indeed what's listed in #2845. @MD3XTER can you confirm that assumption? |
@bmunkholm yes, I would say so. Let's close this issue and track #2845 instead. Thank you all for your help, hopefully, we can find a solution for this! |
j Hello, I am using Realm in a React Native project and I am experiencing some performance issues. Maybe this is normal, but it's too slow for me. Or maybe my implementation is wrong...
Goals
I want to write 600 elements into a realm database at a very fast speed. For the sake of the test I am writing just 50 elements, but it's still very slow and writing 600 elements into realm will block JS thread for too long.
Expected Results
I expect that writing 50 elements into Realm to be faster than writing into AsyncStorage. Preferably to take no more than 1-50 ms.
Actual Results
Realm Benchmark
AsyncStorage Benchmark
Code Sample
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: