View Single Post
Old Mar 21st, 2007, 5:12 PM   #20
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I'm not saying you can't do your own caching. Critical applications obviously do. I'm saying that you need to make sure you don't buck or duplicate what the OS is doing. Good database apps use low-level IO/file system operations to avoid it.

The OS does a couple of things. One is cache and one is virtual memory. They aren't precisely the same thing. If you work directly with the file system, you will avoid OS caching. If you use dynamic memory, you will kick in the virtual memory operations. I don't know precisely what Python offers, even though it's based on C/C++. In C/C++, aside from dynamic memory, you can memory map a file. The OS takes care of keeping that synced up with the disk.

If the frequency of access of various objects is random, there's very little you can do. Objects which are used more often than others need to bubble to the portion of the collection which is currently mapped into memory or is able to be accessed with minimal latency/access time on the drive. I think that's what you're trying to do, which is fine. I'm just saying you CAN degrade the operation if you don't make sure you and the OS aren't handling the same stuff twice when once (and quickly) is what you want.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote