tworld icon indicating copy to clipboard operation
tworld copied to clipboard

Code caching

Open erkyrath opened this issue 11 years ago • 2 comments

Retain parsed {text} and {code} objects, globally. (And {gentext} when that's in place.) Key them by the raw text. Conveniently, parsing of these types never depends on world context.

When to discard cache entries? Least-recent-use, or hook into the instance pool? (We'd want to share entries across instances, so we can't just throw them away when the instance sleeps. But we don't want to keep entries around when all instances of a world are asleep.)

erkyrath avatar Aug 27 '13 17:08 erkyrath

Note this is not the same as property caching. This doesn't care where the object came from, only what obj['text'] parses to.

Logically it would even make sense to cache these objects in the DB rather than in memory. However, there's no DB storage of ast.parse() trees, etc. Keeping pickled objects might be faster than repeated parsing, but I am skeptical.

erkyrath avatar Aug 27 '13 17:08 erkyrath

Will eventually need a way to limit the cache pool size, on top of whatever other discard scheme we have.

erkyrath avatar Aug 27 '13 17:08 erkyrath