Message Boards Message Boards

Disabling System Cache (not ClearSystemCache)

Posted 1 year ago

Hi,

The caching function is great for doing things rapidly when some thing has already been done before... so long as the time to search the cache is less than the time needed to execute a function. It is also only great when only a "small" number of things have been executed, but as the number of things executed increases the cache eats huge amounts of memory, potentially requiring the use of virtual memory which in turn really slows things down a lot. Yes, one can write code that periodically executes ClearSystemCache but that only cleans up the mess after it has happened. I often run code that executes billions of symbolic operations with very few things being repeated - making the System Cache more of a headache than a help. So is there a way to prevent Mathematica from ever caching results? Also, I only do local computing, so anything thing web or cloud related is of no help to me (to benefit others, feel free to provide answers about disabling caching for web or cloud computation).

POSTED BY: Troy Wahl
3 Replies
Posted 1 year ago

Hi Jason,

I just tested that with my code and for a very small dataset (8 items) it improves speed by ~1.3% (5.757 s -> 5.684 s), and for a slightly larger dataset (210 items) by ~4% (165.150 s -> 158.59 s). I expect it to greatly increase my speed as the datasets larger (I'll have datasets with 10,000s of items).

Thanks again.

POSTED BY: Troy Wahl
Posted 1 year ago

Thank you Jason, I'll try that.

POSTED BY: Troy Wahl

This should do what you are asking, I don't have any idea how it affects performance.

Scan[
    SetSystemOptions["CacheOptions" -> (# -> ("Cache" -> False))]&,
    Keys["CacheOptions" /. SystemOptions["CacheOptions"]]
]
POSTED BY: Jason Biggs
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract