-
Notifications
You must be signed in to change notification settings - Fork 27
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
Memory consumption with large archives #122
Comments
Thanks for the issue report.
Since this sounds like a memory leak, it is a bug, thus I cannot currently think of any workaround until the root cause is found. |
no, it really looks like this:
it's not even possible to finish the list operation. so
I've never had experimented with such large archives so can't really tell whether this might be a regression. Please note that listing the archive contents takes several minutes:
I used the defaults as you can see above.
Arch Linux, current |
Ok, very interesting. I cannot say that specific use-case have been tested before. Btw, looks like it takes seconds, not minutes from the output you presented from |
Unless there is some sensitive information in that archive, could you please try to rebuild rar2fs using Also please try v1.28.0, need to understand if this might be related to some of the problems that was discovered with v1.27.2 recently. |
approx 170 000 files
you should be looking at total, so it took 6 minutes 41 seconds. |
Yea, my bad. This is definitively not a use-case that has been tried before. It is also does not sound like a memory leak from where I stand. Something is requiring a lot of resources bound to the number of files. |
Ok, did some quick calculations. Just keeping the files in the cache will take ~2GB of memory. |
Maybe, just maybe, we could experiment with some archive scanner that only searches files on a certain directory depth. It would require a lot more processing though so I am not really sure it is worth it. Also I am rather certain the use-case you are putting up here is not one of the more common ones, which of course makes it even more difficult to motivate such a feature. What I do not like is that you get a crash. Is it a OOM killer you get or something else? EDIT: If it is something else, can you try to catch it in gdb or something so that we can check where exactly it fails. We are supposed to have checks everywhere for memory allocation failures but it might still be missing in a few places. |
This is where the problem might be
It is not something I can confirm yet, but the pre-collection of all files before processing might not be such a good idea if the archive holds a lot of files, like in this case. I will try to find some time to look at it. I will need your help though to verify if it works or not. The time it takes to extract the information is nothing we can improve though. If it takes ~6(!!) minutes using |
Please try this patch on master/HEAD and report back. From the root of the rar2fs repo do: EDIT: Note, patch was changed. |
Note that this patch is needed so please report back as soon as you have been able to test it. There are some more issues with very large archives as explained in issue #124, But without this patch memory is most likely running out before those problems are going to manifest themselves. |
Sorry for the delayed response. I was able to mount and list the mountpoint with both patched and unpatched version of Both versions were compiled with debugging enabled and ran with Here are my observations:
|
Thanks for the report. It seems odd that the patched version is that much slower than the original version? I would appreciate if you could do a few more benchmarks of the patch. Again, it should not perform that bad compared to the original version. Also, turn off debugging. |
Did another benchmark using a recursive |
Did I mention that my archive is flat? There are no subdirs, just files. So |
Ok, that is good to know. But it still should not perform worse with the patch. I cannot explain that, especially not since I observe the exact opposite. |
Thinking about the best way to observe the effect of patch on memory. Can you recommend something? |
What you could try, if not already, is something like |
I used the attached scripts to produce graph of first invocation of |
Very nice graphs :) But something seems inconsistent. In the first runs, it looks like the patched version is using a lot less memory, but then suddenly the patched version starts to show it is using more memory!? Truly do not understand this. Given what the patch does it cannot/should not consume more memory than the non-patched version. |
Memory requirements aside do you have any idea why it takes more time for patched version to do the same job? |
No sorry, it really makes no sense :( I see the complete opposite effect of the patch here. I have never seen such a huge flat archives before. Just the fact it takes minutes even for Maybe the speed difference also boils down to memory requirement? |
Btw, was the What happens if you do |
| Btw, was the ls -l always made after ls -f? Yes, it was. Maybe I can run it again like this: |
Why do you use |
Can you please try to mount using the |
well the idea was to have a reference points so that we can compare it to the memory report. but sure.. a long running loop is a better idea. |
I ran this night with Note that once files has been listed, they are all in the cache. Repeated list operations would only pick data from the cache and thus no memory is really allocated. That is why I am surprised to see that while running without |
I have executed a bit more extensive tests now and I think we can exclude a memory leak. But it is worth mentioning that running in multi-threaded mode takes (in my tests I need to point out) about 6-7 times more virtual- and about twice as much resident- memory. That is not completely unexpected since the additional threads created and maintained by FUSE does not come for free. Note that memory overhead in multi-threaded mode is only for system/library internal bookkeeping etc. not really related to rar2fs, The amount of memory required for the file- and directory cache stays the same irrespective of which mode is used. |
I have run the patched version over night without |
Did you try with |
When scanning an archive for files a linked list it created with all files and properties before being processed by file system functions such as readdir. This cause some memory overhead since a lot of data is required to be kept resident for a longer period of time. Since the lifetime of the data collected is relatively short there is not need to pre-fetch all information like this. Instead handle file by file and use only a single temporary object to hold whatever meta data is necessary. The performance is also expected to be improved by a change like this since less dynamic heap allocations are required but it also results in a loop unwind that will increase number of functions calls. Measurements of some common use-cases indicated a performance increase of approximately 15%-20% but there are also reports of no improvement at all or even the opposite. The latter should however be considered a rare and exceptional case. This change was triggered by issue #122 for which a very huge archive was mounted with more than 100k files. Signed-off-by: Hans Beckerus <hans.beckerus at gmail.com>
If this is something to worry about depends heavily on what memory usage is really increasing. |
I don't really see RES column in the data provided by
|
When scanning an archive for files a linked list it created with all files and properties before being processed by file system functions such as readdir. This cause some memory overhead since a lot of data is required to be kept resident for a longer period of time. Since the lifetime of the data collected is relatively short there is not need to pre-fetch all information like this. Instead handle file by file and use only a single temporary object to hold whatever meta data is necessary. The performance is also expected to be improved by a change like this since less dynamic heap allocations are required but it also results in a loop unwind that will increase number of functions calls. Measurements of some common use-cases indicated a performance increase of approximately 15%-20% but there are also reports of no improvement at all or even the opposite. The latter should however be considered a rare and exceptional case. This change was triggered by issue #122 for which a very huge archive was mounted with more than 100k files. Signed-off-by: Hans Beckerus <hans.beckerus at gmail.com>
I think this issue can be closed, but there might come reasons to bring up the topic again later. |
When scanning an archive for files a linked list it created with all files and properties before being processed by file system functions such as readdir. This cause some memory overhead since a lot of data is required to be kept resident for a longer period of time. Since the lifetime of the data collected is relatively short there is not need to pre-fetch all information like this. Instead handle file by file and use only a single temporary object to hold whatever meta data is necessary. The performance is also expected to be improved by a change like this since less dynamic heap allocations are required but it also results in a loop unwind that will increase number of functions calls. Measurements of some common use-cases indicated a performance increase of approximately 15%-20% but there are also reports of no improvement at all or even the opposite. The latter should however be considered a rare and exceptional case. This change was triggered by issue #122 for which a very huge archive was mounted with more than 100k files. Signed-off-by: Hans Beckerus <hans.beckerus at gmail.com>
My primary system has 8 GB of RAM, rar archive I am mounting has size of more than 350 GB. While
rar2fs
does not complain, any attempt to list mountpoint or change to it slowly consumes all available ram (w/o touching swap) and ultimately results in coredump.I'd like to learn if there is a way to overcome this issue e. g. at the expense of speed. Or at least how much memory is needed for large files.
The text was updated successfully, but these errors were encountered: