From: SourceForge.net <no...@so...> - 2005-03-17 21:57:06
|
Feature Requests item #563113, was opened at 2002-05-31 16:28 Message generated for change (Comment added) made by soulcatcher You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=384722&aid=563113&group_id=25576 Category: Code Related (Add/Del/Improve) Group: None Status: Open Resolution: None Priority: 5 Submitted By: Scott Ellsworth (scottellsworth) >Assigned to: Frugal (frugal) Summary: PObject needs to be lighter weight Initial Comment: Merton: assigned to you, as this is a VERY deep change in data access, and it would not be kind to just dig in without your express approval of the design and methodology. The program is quite solid in general, but we keep getting speed and memory complaints. There are many places this could be attacked, but probably the best way is to make PObject a lighter weight class. This is not an attack on the design, only a comment on how it has developed as the program has grown to support an amazing number of supplements. Running a few profiles shows that we create a staggering number of array lists, char arrays, and strings during program load - up to 60 thousand of the first, and several million of the next two during the load of a fairly small party of four. This is happening at least partially because PObject is fairly heavyweight. For example, we create several blank array lists and object arrays for every pobject, most of which are empty, if I am understanding my profiler output properly. Then, during use, the vast majority of uses ask for an iterator for these empty objects. This means that we have to create thousands of iterators for primarily empty objects. The creations take time, and use a lot of RAM. One easy solution - remove direct array list access to the array lists in PObject. Instead, provide a method that returns an iterator. Then, provide setter methods that will add to the array lists underlying PObject. Thus, we will have controlled access to the underlying data, and we will then be able to select containers more appropriate to the usage patterns we need. Further, we can set the array lists and other items to a single noll, EMPTY_LIST or EMPTY_MAP rather than to individual empty lists. We could then return a single empty iterator for these objects, rather than having to create a new one each time the user asks for one. As a bonus, the iterator is unmodifiable, so there would be no way for someone to sneak an entry into the empty lists. Once someone calls the "add" method I have proposed adding to PObject, we create a new collection. Calls to iterator would then create new objects, but I suspect we would see far fewer of them. This would, at the least, dramatically cut down on the number of objects we need to create as the program spins up, loads sources, and loads a party of characters. We would also save tons of RAM. It might be worth investigating whether we could generate a single parser for an input line in an lst file, rather than using StringTokenizer. We end up needing a LOT of these tokenizers, and they are often extracting text we do not directly need - rather, we need to know whether a given keyword matches the text we would extract. It might be possible to do this purely by parsing out start and end indices, and providing a "get value for key" method that compares a given region in a string to the desired key, and extracts the value only if there is a match. Scott ---------------------------------------------------------------------- >Comment By: Devon Jones (soulcatcher) Date: 2005-03-17 14:57 Message: Logged In: YES user_id=107647 Frugal, assigning this to you so you can close it when cdom gets committed. ---------------------------------------------------------------------- Comment By: Scott Ellsworth (scottellsworth) Date: 2004-02-12 18:10 Message: Logged In: YES user_id=331345 Ask me again in a few weeks - pcgen is crashing my profiler ---------------------------------------------------------------------- Comment By: Martijn Verburg (karianna) Date: 2004-02-02 21:43 Message: Logged In: YES user_id=252169 karianna kicks scott. Unfortunately refactoring that code is beyond the time I have, could you re-run your tool and see how bad we are now? K TM SB ---------------------------------------------------------------------- Comment By: Martijn Verburg (karianna) Date: 2003-08-31 20:28 Message: Logged In: YES user_id=252169 I will also be looking @ improving this during my Javadoc phase ---------------------------------------------------------------------- Comment By: Martijn Verburg (karianna) Date: 2003-08-31 20:28 Message: Logged In: YES user_id=252169 I will also be looking @ improving this during my Javadoc phase ---------------------------------------------------------------------- Comment By: Martijn Verburg (karianna) Date: 2003-08-20 04:09 Message: Logged In: YES user_id=252169 Can you run it again? I'd like to close this freq and open more specific ones... ---------------------------------------------------------------------- Comment By: Scott Ellsworth (scottellsworth) Date: 2003-08-08 10:22 Message: Logged In: YES user_id=331345 This is still relevant, and will remain so until we end up with distinct keys in known case with dependency based calculations. This is, of course, non trivial to write correctly, so we probably do not want to muck with it casually. The recent changes have been good; the bottlenecks appear to be in the bonus and variable calculation. I am waiting for the BonusObj dust to settle before running the profile again. ---------------------------------------------------------------------- Comment By: Bryan McRoberts (merton_monk) Date: 2002-06-10 20:45 Message: Logged In: YES user_id=195874 Scott, much of your great advice has been done. More can always be done... could you re-run your profiler and see how it looks now? It would be interesting to know if other bottlenecks can now be identified if we've hit all the major ones in PObject. ---------------------------------------------------------------------- Comment By: Greg Bingleman (byngl) Date: 2002-06-02 13:26 Message: Logged In: YES user_id=328527 Not really a bug, moving to FREQs ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=384722&aid=563113&group_id=25576 |