You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With 27M documents, the user reports on-disk size of 56GB.
Looking at the sample documents, they're between 100-256 bytes in size. Even if we assume 512 bytes, back of the napkin math suggests raw size should be about 12GB. Double that because the btree is half full or some such, and double it again because of GC (that sounds bad), and we get ~48GB. However, we're may be a factor of 4-8 off from raw data size.
We should look into what's going on here again, and do one (or more) of the following:
Fix what we can
Test other comparable systems
Publish data relative to other systems to assuage user fears (or instill fears into our own hearts)
dev@mongodb-0:/var/lib$ du -ch mongodb/
3.2M mongodb/journal
15G mongodb/
15G total
I run this command last night :
nohup rethinkdb import -c localhost:28015 --table pampa.raw_clicks -f qu_pap_rawclicksBK20140522.json --format json --force
When I woke up, my dev server was with disk usage 100%. I run Digital Ocean 8GB instance.
Yup, I think so. I was confident that would not happen, I was more worried about RAM for example.
I can give you another example. I have just imported the same data into another DB that I'm testing: ArangoDB. and It usage is 6.7 GB.
@danielmewes -- I have a vague memory that we store documents < 256 bytes efficiently, but that between 256 bytes and 4096 bytes we use a full 4096. Is that still (or was it ever) true?
If so, that last piece of click data looks like it serializes to just over 256 bytes. If some of the click objects are taking up 4k instead of 256b, that would explain the high disk usage.
@mlucy -- At one point that was true but it's no longer the case. @srh made a number of changes and we're now at 512b chunks rather than 4096b. So, if the document is > 256 bytes (ignoring metadata and such), it will take 512b of disk space.
@diegogub -- we'll investigate and make improvements (there are lots of things we can do), but unfortunately we can't do very much in the short term. If disk space utilization is important, you'd probably be better off with a different database. We do hope you come back and give RethinkDB a try again in a few months!
@diegogub Thank you for the report.
An additional question: I saw that you used --force in the import command. Did you import into tables that were already existing?
Had those tables been used before? If yes, have there previously been secondary indexes on those tables that you had since deleted?
There is a known leak of disk space when deleting a secondary index (the space isn't freed). If you later re-create the same index, you'll end up with twice the space usage for the index.
That being said, I've seen higher than expected space usage before. We'll definitely investigate it and can hopefully implement some improvements soon (though as @coffeemug says it will likely take a few months).
@danielmewes No, it was a new tables created for the migration. It was never used before. Thank you for your fast replies. I was considering rethinkDB mostly because easy replication and sharding. So anyway, I will evaluate if I can deal with a limited number of records per batch. And maybe start pre aggregating my data in smaller chunks and delete processed documents.
Just to drop my two cents i think the best way to look into this will be to run rethinkdb in nodirecio and then run strace dtrace or your favorte tool and see how large it says the writes its commiting to disk.
@diegogub I have one more question about your data: Is one of the fields in your documents the primary key or do you use auto-generated primary keys (i.e. did you specify a primary key different than id when creating the table)?
That means that from the 1.2 GB data file, 973 MB are garbage.
In this experiment, I had inserted a little more than 1 million documents of approximately 100 bytes each, resulting in a raw data size of roughly 100 MB.
@coffeemug An absolute number would be tricky, because GC becomes incredibly inefficient if the absolute number is too small compared to the table size.
What could work is to keep a fixed minimal garbage ratio internally, but allow the user to additionally specify an "acceptable amount of garbage" in absolute terms.
We would take the maximum of both to determine whether to increase the GC's aggressiveness.
After thinking about this more, I don't really like either idea (I mean exposing anything about gc to the user in general). This sort of config option opens up a certain class of questions -- what should I set it to? what's a reasonable value here? why do I have to set this? etc. I think it's best not to expose anything at all, and pick a value we know to be reasonable. @danielmewes -- what do you think?
I think the expected behavior is to have tables not use excessive amounts of disk space, and that should work reliably on both SSDs and rotational drives.
I will run some more experiments and see what impact the goal garbage rate actually has on performance. If it turns out that GC becomes a lot more efficient if we allow for a slightly higher garbage rate, I think it would be worth having it configurable (or some related parameter).
We shouldn't be afraid of explaining how RethinkDB and its parameters work. We would make sure that "the reasonable value" would be the default, unless disk space is of little concern for a user.
Large documents
On rotational drives, I repeated the insert 1M documents experiment, but this time with documents of ~1 KB size each.
On v1.12.x, inserting those documents took 4m 5s, and the table size at the end was 5.6 GB.
On daniel_concurrent_gc it took 14m 30s, with a table size of 1.6 GB at the end.
That slow-down seems a bit extreme.
Increasing the GC_HIGH_RATIO
Increasing what's internally called the GC_HIGH_RATIO from 0.3 to 0.45 has the following effect:
In the large value experiment, inserting 1M values now takes 10m 55s. The file size increases only marginally to 1.7 GB. Still significantly slower than in v1.12.x, but a much better compromise.
With 1M small documents as before, the changes are as follows:
On rotational disks, inserting 1M documents takes 6m 24s down from 8m 20s. The file size is now 504 MB instead of 400 MB.
On SSD, the insert time is 52s. The file size is 442 MB (vs. 58s / 400 MB).
I'm going to change the GC_HIGH_RATIO to 0.45 or even 0.5. That seems to provide the better overall compromise between small files and performance.
Activity
coffeemug commentedon May 23, 2014
Diego -- out of curiosity, what disk space utilization do you get if you insert the same documents into MongoDB?
diegogub commentedon May 23, 2014
I have :
dev@mongodb-0:/var/lib$ du -ch mongodb/
3.2M mongodb/journal
15G mongodb/
15G total
I run this command last night :
nohup rethinkdb import -c localhost:28015 --table pampa.raw_clicks -f qu_pap_rawclicksBK20140522.json --format json --force
When I woke up, my dev server was with disk usage 100%. I run Digital Ocean 8GB instance.
Regards
Diego
coffeemug commentedon May 23, 2014
So it's 48GB in RethinkDB vs 15GB in MongoDB for exact same dataset (a factor of 3)?
diegogub commentedon May 23, 2014
Yup, I think so. I was confident that would not happen, I was more worried about RAM for example.
I can give you another example. I have just imported the same data into another DB that I'm testing: ArangoDB. and It usage is 6.7 GB.
mlucy commentedon May 23, 2014
@danielmewes -- I have a vague memory that we store documents < 256 bytes efficiently, but that between 256 bytes and 4096 bytes we use a full 4096. Is that still (or was it ever) true?
If so, that last piece of click data looks like it serializes to just over 256 bytes. If some of the click objects are taking up 4k instead of 256b, that would explain the high disk usage.
coffeemug commentedon May 23, 2014
@mlucy -- At one point that was true but it's no longer the case. @srh made a number of changes and we're now at 512b chunks rather than 4096b. So, if the document is > 256 bytes (ignoring metadata and such), it will take 512b of disk space.
@diegogub -- we'll investigate and make improvements (there are lots of things we can do), but unfortunately we can't do very much in the short term. If disk space utilization is important, you'd probably be better off with a different database. We do hope you come back and give RethinkDB a try again in a few months!
danielmewes commentedon May 23, 2014
@diegogub Thank you for the report.
An additional question: I saw that you used
--forcein the import command. Did you import into tables that were already existing?Had those tables been used before? If yes, have there previously been secondary indexes on those tables that you had since deleted?
There is a known leak of disk space when deleting a secondary index (the space isn't freed). If you later re-create the same index, you'll end up with twice the space usage for the index.
That being said, I've seen higher than expected space usage before. We'll definitely investigate it and can hopefully implement some improvements soon (though as @coffeemug says it will likely take a few months).
diegogub commentedon May 23, 2014
@danielmewes No, it was a new tables created for the migration. It was never used before. Thank you for your fast replies. I was considering rethinkDB mostly because easy replication and sharding. So anyway, I will evaluate if I can deal with a limited number of records per batch. And maybe start pre aggregating my data in smaller chunks and delete processed documents.
wojons commentedon May 26, 2014
Just to drop my two cents i think the best way to look into this will be to run rethinkdb in nodirecio and then run strace dtrace or your favorte tool and see how large it says the writes its commiting to disk.
avolochenko commentedon May 29, 2014
Having similar issue my sample document is:
{"url":"http://someurl","status":"some_status"}
which is average of 120bytes on disk, with 25million documents inserted my RethinkDb table is ~17GB , vs ~2.4GB on disk
coffeemug commentedon May 29, 2014
Marking as high priority.
danielmewes commentedon May 29, 2014
@diegogub I have one more question about your data: Is one of the fields in your documents the primary key or do you use auto-generated primary keys (i.e. did you specify a primary key different than
idwhen creating the table)?danielmewes commentedon May 29, 2014
One problem is that the garbage collector doesn't keep up when inserting data as fast as possible:
Excerpt from
ajax/stat:That means that from the 1.2 GB data file, 973 MB are garbage.
In this experiment, I had inserted a little more than 1 million documents of approximately 100 bytes each, resulting in a raw data size of roughly 100 MB.
20 remaining items
coffeemug commentedon Jun 5, 2014
This used to be configurable via command line. Did we take that out?
BTW, I think a ratio is a bad way to expose this because:
I think that if we expose this, we should expose a flat number in megabytes. That sounds much easier to understand (and more useful).
danielmewes commentedon Jun 5, 2014
@coffeemug An absolute number would be tricky, because GC becomes incredibly inefficient if the absolute number is too small compared to the table size.
What could work is to keep a fixed minimal garbage ratio internally, but allow the user to additionally specify an "acceptable amount of garbage" in absolute terms.
We would take the maximum of both to determine whether to increase the GC's aggressiveness.
Does that sound reasonable?
coffeemug commentedon Jun 5, 2014
After thinking about this more, I don't really like either idea (I mean exposing anything about gc to the user in general). This sort of config option opens up a certain class of questions -- what should I set it to? what's a reasonable value here? why do I have to set this? etc. I think it's best not to expose anything at all, and pick a value we know to be reasonable. @danielmewes -- what do you think?
danielmewes commentedon Jun 5, 2014
I think the expected behavior is to have tables not use excessive amounts of disk space, and that should work reliably on both SSDs and rotational drives.
I will run some more experiments and see what impact the goal garbage rate actually has on performance. If it turns out that GC becomes a lot more efficient if we allow for a slightly higher garbage rate, I think it would be worth having it configurable (or some related parameter).
We shouldn't be afraid of explaining how RethinkDB and its parameters work. We would make sure that "the reasonable value" would be the default, unless disk space is of little concern for a user.
danielmewes commentedon Jun 6, 2014
More effective garbage collection is in next as of 67e772c and will ship with 1.13.
Let's track the remaining part, improving the shrinking mechanism for table files, in #1830.
danielmewes commentedon Jun 7, 2014
More experiments:
Large documents
On rotational drives, I repeated the insert 1M documents experiment, but this time with documents of ~1 KB size each.
On v1.12.x, inserting those documents took 4m 5s, and the table size at the end was 5.6 GB.
On daniel_concurrent_gc it took 14m 30s, with a table size of 1.6 GB at the end.
That slow-down seems a bit extreme.
Increasing the GC_HIGH_RATIO
Increasing what's internally called the
GC_HIGH_RATIOfrom 0.3 to 0.45 has the following effect:In the large value experiment, inserting 1M values now takes 10m 55s. The file size increases only marginally to 1.7 GB. Still significantly slower than in v1.12.x, but a much better compromise.
With 1M small documents as before, the changes are as follows:
On rotational disks, inserting 1M documents takes 6m 24s down from 8m 20s. The file size is now 504 MB instead of 400 MB.
On SSD, the insert time is 52s. The file size is 442 MB (vs. 58s / 400 MB).
I'm going to change the GC_HIGH_RATIO to 0.45 or even 0.5. That seems to provide the better overall compromise between small files and performance.
danielmewes commentedon Jun 7, 2014
Changed GC_HIGH_RATIO in CR 1605 by @Tryneus
danielmewes commentedon Jun 7, 2014
Parameter changed in next 4496039