Flushing Wasted DFN Data...

Want to discuss changes to the UOX3 source code? Got a code-snippet you'd like to post? Anything related to coding/programming goes here!
Post Reply
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Flushing Wasted DFN Data...

Post by giwo »

I've kicked this topic around for a while, but figured it's about time to bring it up again.

Firstly it would be important to mention that ALL of our DFN files are cached into memory and kept there until the program is exited. While this is necesarry to prevent slowdowns in some scenarios, this turns into wasted memory in other cases.


There are two basic types of DFN's that UOX3 has. There are the DFN's we all immediately think of, Items and NPC's, and a few assorted others. These scripts are constantly used as the game runs and thus for performance reasons MUST be kept in memory.

However there is a second type, these are scripts such as (Guard/Town) Regions, SpawnRegions, Titles, Teleport Locations, Creatures, Locations, and possibly others. All of these scripts are loaded in as strings, and then pushed into structs and classes contained in the CWorldMain class for easy handling. At this point, it is my belief that we should flush the script entrys out for these particular scripts, saving ourselves quite a bit of wasted memory.

Basically what I'm wanting are thoughts regarding this situation, ideas on how to best go about implementing a good dynamic flushing system, and other opinions in general.

Thanks ;)
Scott
Sydius
UOX3 Apprentice
Posts: 171
Joined: Thu Mar 25, 2004 3:22 am
Has thanked: 0
Been thanked: 0

Post by Sydius »

I believe the best way to go would be to write a general-purpose script-caching manager. I do not know exactly how it is handled right now, but I could envision usage somewhat like this:

CScriptHandle h = CScriptManager->GetSingleton().GetScript(“ScriptName”);

The real work would be done in GetScript. Using various caching techniques, it would first determine if the script is already in memory, and, if so, return it, or else load it into memory and return it. Either way, it would also keep track of how often that particular script is accessed (either by time or just a simple ordering system), and dump any from memory that are rarely accessed.

This would also make it easy to specify exactly how much RAM may be devoted to caching of scripts (in a worst-case scenario).
Post Reply