Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rubyzip vs native OS compression

Tags:

ruby

zip

rubyzip

I am wondering what would be the performance difference when zipping data using rubyzip as compared to using native os libraries for performing the compression. I am fetching data to be compressed from a URL and then using the ZipOutputStream to create the zip file. In case of native OS utilities I am thinking of using the zip tool. Would be nice to hear some pros and cons for both the approaches.

like image 749
randomuser Avatar asked Feb 09 '11 10:02

randomuser


2 Answers

It turns out that there is not much of a difference in terms of the time taken for the operation or the CPU usage. But there was a significant difference when it came to memory usage. With rubyzip the process ended up using a lot more memory compared to when using the zip util. In our use case memory usage was a significant concern and hence we ended up using the zip util.

like image 136
randomuser Avatar answered Oct 22 '22 22:10

randomuser


If you are pulling the data from the web, it is doubtful the bottleneck will be rubyzip. I doubt you will see much of a performance difference as it will mostly be limited by the speed of you web connection. Plus rubyzip uses native libraries to do most of the work. Probably will work just fine and I would be very surprised if it was much slower for this type of application. Now if you were concerned about how many CPU cycles it took because thousands of threads would be running at once, then you might want to use the gnu C libraries.

like image 1
OTrain Avatar answered Oct 22 '22 20:10

OTrain