WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: (z)chache eating memory on filecopy  (Read 3405 times)

Offline helasz

  • Newbie
  • *
  • Posts: 36
(z)chache eating memory on filecopy
« on: January 12, 2012, 03:02:37 AM »
Hi All,

I am running TC 4.0 (no particular boot options, just "text multivt") on a hardware with 2GB RAM. If I copy a file comparable to that size it is all cached (according to /proc/meminfo), and then it keeps to be there, performance is drammatically lost.

1) TC should automatically empty the cache, should it not?

2) is there a way to switch off the cache or limit its size? zcache says at booting to use the default 25% of the amount of memory (which would be fine with me) but apparently it does not limit the cache size at all.

Any suggestion?



Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11634
Re: (z)chache eating memory on filecopy
« Reply #1 on: January 12, 2012, 09:56:59 AM »
Hi helasz
Where are you copying it to? If, for example, you copy it to your  home  directory, and it is not
persistent, it will wind up in RAM.
Quote
1) TC should automatically empty the cache, should it not?
No. Please take a minute to read the following:
http://forum.tinycorelinux.net/index.php/topic,9769.msg53362.html#msg53362
http://www.linuxatemyram.com/  (Thanks to gerald_clark for this one)
Quote
performance is drammatically lost.
That's pretty vague. You boot in  text  mode and say that performance is dramatically lost. The machine
can no longer keep up with the rate at which you type?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: (z)chache eating memory on filecopy
« Reply #2 on: January 12, 2012, 10:16:18 AM »
You can disable zram with the "nozswap" bootcode.

But I agree with Rich, it does sound like your huge file ended up in ram. In that case zram probably saved you from a crash.
The only barriers that can stop you are the ones you create yourself.

Offline helasz

  • Newbie
  • *
  • Posts: 36
Re: (z)chache eating memory on filecopy
« Reply #3 on: January 13, 2012, 04:22:29 AM »
Thansk for both of you for answering!

I am definitely not copying into my home dir, I am working with huge (1 to 6 GB) files which (not rarely) need to be copied between partitions for various reasons. Speed of first copying is just fine, after that copying (and compiling source codes which is my other primary concern) speed is going down remarkably (maybe drammatical is however not the appropriate term).

I see I was wrong in identifying the point. I thought (because meminfo lead me think that) it was a cache issue, I was searching the forums for "cache" and so has not found the (by Rich) linked thread which clears up the cache mechamism I was not aware of.

I consider this topic solved.

Thank you!

P.S.: I am keeping not to be sure of the reason of my performance loss, but at this point I am going to search the cause elsewhere in my system.




Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11634
Re: (z)chache eating memory on filecopy
« Reply #4 on: January 13, 2012, 12:08:40 PM »
Hi helasz
OK, now we have enough information to identify what is happening. When you copy a file, it gets
opened for reading and is promptly cached by the operating system. I you do that with a large
enough file, it will replace the current cache contents with whatever was read last. Although I have
not tried this, I suspect that if you copy a large enough directory of small files, the result will be the
same. Here is a simple test I did using the  time  command  on a compile script and a  cp  command.
1. time ./compilecreaterootlist            (0.73Secs, the command was previously cached)
2. time cp /mntt/bb/devil.iso /dev/null  (93.4Secs, copied from Samba server, Pentium233Mhz, 256Mb)
3. time ./compilecreaterootlist            (2.4Secs, the command was no longer cached)
4. time ./compilecreaterootlist            (0.72Secs, the command was once again cached)

The  ISO  file was 427Mb. The machine I ran the commands on is an 800Mhz P3 with 512Mb. The
following applications were running at the time: terminal, MC, 5 copies of editor, wireshark, geany, and
AppBrowser.

Offline helasz

  • Newbie
  • *
  • Posts: 36
Re: (z)chache eating memory on filecopy
« Reply #5 on: January 16, 2012, 03:03:38 AM »
Hi Rich,

Thanks a lot for your testing and accurate answer (and time you have taken for that)! It is much appreciated!


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11634
Re: (z)chache eating memory on filecopy
« Reply #6 on: January 16, 2012, 03:09:56 AM »
Hi helasz
You are welcome.