uskudnik / amazon-glacier-cmd-interface

Command line interface for Amazon Glacier
MIT License
374 stars 100 forks source link

Memory problems: SOLVED. #61

Closed wvmarle closed 12 years ago

wvmarle commented 12 years ago

Believe it or not, a single = sign completely solves the excessive memory use. I'm very surprised by this result. No need for memoryview so fully python 2.6 friendly. Proper code:

glaciercorecalls.py:324 while self.buffer_size >= self.part_size:

I tested it with a 128 MB chunk and the old code NOT using memoryview, and the results are stunning. Total memory use was: 640 MB With memoryview: 512 MB With this fix, and the orginal string-based code: 128 MB.

This works as long as the writer gets fed the correct block size, so when a complete block is in the buffer it can send out this complete block. Smart python will continue to refer copies of this buffer to the same memory location, and thus not use any extra memory.

Original situation:

New situation:

Wow, what a difference a single character can make!

For this analyses I used heapy to get memory use at various points in the program (use the svn trunk for python 2.7).

offlinehacker commented 12 years ago

Thanks, what about pull request? I still think memoryview should be there in case of python 2.7

wvmarle commented 12 years ago

I have open pull requests; github doesn't let me create one.

Memoryview or array suddenly doesn't make a difference as in either case there is one block in memory..

uskudnik commented 12 years ago

Hmm... didn't know github only lets you create only one... I'll try to merge your existing one ASAP.

wvmarle commented 12 years ago

Merge done; time to close this one.