|
|
Speed Considerations and the MiscKit | |
|
|
Most recent update was on February 7, 1996. If you'd like to submit something to the FAQ or update something in the FAQ, feel free to contact Don Yacktman or use our handy FAQ submission form.
Speed Considerations and the MiscKitThe novice's reaction would be to ask if removing the convenience methods from the MiscString would have much effect on the end performance of an application. It actually doesn't matter. You could have a billion methods and they won't really affect the performance very much. It is roughly the same as having a billion C functions linked into your app. They take up space, but don't affect the speed of the other functions. The exception to this is when you are calling convenience methods, which often just add default parameters and then call a "core" method. Speedups can be obtained by calling the core method, filling in the extra parameters with default values that you like. Here's a few random thoughts that aim towards being a general scheme for developing faster apps:
I do this for every project where speed is critical, and repeat it each time because I end up tuning things in different ways to accomodate my app. This is a nasty, non-OOP approach to take, but when speed is critical you have to break the rules to really get it running fast. The tradeoffs are that you have to know what you are doing and be incredibly careful. I don't like to advocate breaking rules because it is bad practice, but I feel there are times when exceptions are warranted and can be justified. I feel this approach breaks rules of pure OOP because you are opening up the "black box" that is the MiscString and fiddling with it, which in an ideal situations shouldn't be done and shouldn't be necessary. In this case I justify it by saying that I am altering the code to create a new object that is following different design goals: speed and efficiency over safety and convenience. So ultimately, the question is - is MiscString too fat? In my opinion the interface is too bulky, but other than that it does fulfill its design goals. Other string classes--with other goals--will be quite different and you may decide that they are better for your project. Most people like the bulletproofing and the functionality of MiscString and are willing to sacrifice some performance to get it. Someday we'd like to better tune the MiscString for speed, but that has not really been feasible to date. We haven't purposely written slow methods. The things that make them slow are all the safety checks that are in place and the flexibility of the methods. The checks are obviously a slow down because they take time. The flexibility isn't quite as obvious. Basically, we have to use parameters and other checks to control loops and other flow structures in the code, rather than hard coding certain behaviors. This increases the flexibility of the methods while slowing them down by adding code. Since the MiscString's design calls for safety and flexibility over speed, this is perfectly reasonable. We have optimized the methods for speed as much as is possible given the design goals. With the move to OPENSTEP, I think I'll be able to do several things that will help to speed up the MiscString. That is the plan, at any rate. Because of the Foundation Kit's memory allocation schemes, we should be able to boost performance in several ways, since a lot of the performance hit comes from bringing MiscString objects into and out of scope so often. The FK can help alleviate a bit of that, especially for operations that copy constant strings. Now, moving on to the rest of the kit, what can we do to improve performance? Remembering that 90% of the speedups take 10% of the effort, I personally believe that you'll hit that break-even point before you finish optimizing the MiscString, especially for any app that does a lot of string manipulation. Much of the MiscKit relies heavily upon the MiscString, so speeding up string operations will actually affect the rest of the kit quite a bit. (The MiscMergeKit will show a marked improvement, for example!) If you follow NeXT's hints for speedup in /NextLibrary/Documentation/NextDev/Concepts/Performance you'll end up with a pretty well optimized application. Most of the MiscKit is already quite well optimized for speed, so there really isn't much more that you can do. If, however, you do find ways to obtain major improvements, do be sure to send them in as submissions so that other MiscKit users may benefit! If you have other ideas or comments about this page, please feel free to send them to Don Yacktman via email to don@misckit.com.
| |
|
Questions? Contact our webmaster via email to don@misckit.com. . |
||