Compile unrar for Linux with fallocate #379
Comments
NZBGet doesn't require any unrar patches and works fine with stock unrar. However you are free to use whatever version of unrar you prefer. I'm not sure what do you mean with this issue. Are you suggesting to activate fallocate in the unrar shipped with nzbget? I don't know if I can do that as it may make nzbget installer incompatible with older Linux versions. Currently installer works with kernel 2.6.something whereas I don't know how low "something" can be. Wouldn't fallocating kill unpack perfomance as it needs to fill the whole file with nulls? I wonder why do you modify unrar source instead of using proper compiler flags as intended by unrar author. BTW if Kodi can't play partially downloaded files isn't that something to report to Kodi team? In my tests Kodi also behaves bad on Windows in combination with direct unpack as it blocks files from being moved/renamed. Windows media player works very well in this regard. |
Yes I am suggesting to activate fallocate in the unrar shipped with nzbget. But if it drops the compatibility I will try to report this issue to Kodi team. I thought that it's the easiest method to solve this problem and support more video player.
I have no idea how to measure that. Which program should I use for this test?
Sorry I'm a noob and I have never used a compiler flag. I have written with the unrar author via email some time ago and he recommended me to change his line in source before compile unrar. Nothing about a compiler flag. |
Unrar and nzbget are two different binaries. You can compile unrar yourself and use it with nzbget.
You can pass it via CLFAGS (I haven't tried this but it should work):
Or you can put extra flags into unrar's makefile, which is supposed to be changed by user to adjust to system (added
Since you compile unrar yourself: make two versions with and without fallocate. Then try unpacking the same archive with both unrars, at best do the test multiple times and unpack into convenient HDD. You can use command
|
Thank you very much for the detailed explanation! I will make some tests and report the results. |
unrar without fallocate:
unrar with fallocate:
|
Nice tests! HDD or SSD? |
First I have made some tests on my Desktop PC (Linux Mint 18.1) with an SSD. But the measured times were too different. Still I have seen, that fallocate is faster than without. (If you are interested in the tests I can post them too) The tests above I have made with my little homeserver (CPU while unpack ~30%) and extracted the archive to an HDD because I have no HDD in my Desktop PC. |
The docs for fallocate say it fills the file with nulls. That must take time, right? I can imagine ext4 may have special support for that like marking blocks nullified without actual writing to disk. Do you have a chance to test with other file systems? Ext3 on local drive and ext3/ext4 via samba (NAS) or maybe even ntfs via samba. |
Yes, theoretically it has to cost time. But I'm not an expert :D
|
There is fallocate system call and fallocate console utility. The man page for the utility documents which file systems it supports (only a few actually, including ext4 but not ext3). The man page for system call doesn't mention file systems. I wonder what will happen on a file system which has no special support: will the call fail or will it write the nulls. In the first case the file size will not be set to desired size (you should be able to control that). In the second case it should take long time writing all these nulls. Also intersring is if the ext4 accessed via network can still take advantage or the network protocol will prevent optimizations. In our case I would prefer fallocate quickly to fail on unsupported file systems instead of writing nulls and doubling the unpack time. Thanks for testing this. |
local ext3:fallocate does not work, file is not filled with nulls unrar original:
unrar fallocate:
local ext4:fallocate works, file is filled with nulls unrar original:
unrar fallocate:
local ntfs:fallocate does not work, file is not filled with nulls unrar original:
unrar fallocate:
samba ext3:fallocate does not work, file is not filled with nulls unrar original:
unrar fallocate:
samba ext4:fallocate does not work, file is not filled with nulls unrar original:
unrar fallocate:
samba ntfs:fallocate does not work, file is not filled with nulls unrar original:
unrar fallocate:
BTW who use ntfs in Unix? As said in first comment unrar for Windows preallocs the drive space by default. |
Great testing. Thank you. I'll try to activate fallocate for my unrar build.
The use case is accessing a Windows machine via samba. |
All right, thank you too. |
The next nzbget version will include unrar with fallocate. |
Would you like to try (test) the current version before I release it? If you do - please send me a note to nzbget@gmail.com and I'll send you current installer package. Let me also know your CPU architecture. |
Looks good. Fallocate works and I can play videos while downloading in Kodi now.
After this test I can't agree that Kodi blocks files from being moved/renamed. After the half of video nzbget has moved the file and I was able to watch the video completely (Kodi hasn't already buffered the video). |
Thanks for testing. That's nice Kodi on Linux doesn't prevent the file from being renamed/moved. On Windows it's a different case however. First it opens files in a share mode preventing renaming/moving. Second if file is opened via Kodi's file browser the directory (_unpack) can not be deleted. Windows media player doesn't have these problems though. As for fallocate. For some reason on my Linux box it doesn't work. A test with console command
Although it's ext4 partition and kernel 4.10. |
I have tested with Kodi 17 on Linux and Kodi 16 on Windows both worked great here. But Kodi 17 on Windows stopped video playback after nzbget moved the file, strange... |
When you talk about Kodi on Windows do you playback files downloaded by nzbget on Windows? Fallocate started to work for me after I reformatted the drive to ext4. It turned out the drive was in ext3 although I have a report from nzbget user who tried unpack with fallocate and had a system lockup. After googling I've found a few references where fallocate caused system lockups. I'm looking further into this to decide whether I should revert to default unrar. |
No, in all tests nzbget downloads the file in Linux. Kodi on Windows connects via samba to this Linux machine. |
Hugbug, any testing done (or needed) for ZFS? |
@toddcurry, I believe no one has tested it yet. |
Thank you for the great new features in 19.0-testing-r1991. But I have a small problem with DirectUnpack in Unix in combination with Kodi as video player.
Unrar for Windows preallocs the drive space for extracted files to reduce fragmentation. In Unix the appropriate code is present in unrar source, but not enabled yet, because fallocate call was not
available on older Linux kernels. So in Unix the file size increase with each extracted part. VLC can play these videos but Kodi for example stops playback after a few minutes (after the length of the video at the time of started the playback).
How to fix that: itouch5000/unrarstream@2faa08e
The text was updated successfully, but these errors were encountered: