in reply to Memory /speed questions

Someone has said "Premature optimization is the root of all evil" or something like that. So I try not worry about stuff like this until I have to. My time and user's time is much more expensive than effort on the computer's part, so at some point, good enough really is good enough.

The other answer is "Try it and see". WIth Linux or *BSD, most folks can afford at least a minimal developement environment - and if you're looking for things that cause you to hit limits, small can actaully be better. Start a couple dozen processes doing what you propose and watch the machine in top or vmstat or some such.

--Bob Niederman, http://bob-n.com

Replies are listed 'Best First'.
Re: Re: Memory /speed questions
by BrowserUk (Patriarch) on Jul 30, 2003 at 06:04 UTC

    If the program is short lived and/or runs on a box dedicated to it, then ignoring memory consumption and cpu utilisation is fine.

    However, the sulphuric mentions " 5 hashes on a single page", which I would take to mean he is working in a webserver environment. Excessive memory and cpu utilisation can be can be disasterous in environments where the number of copies if the process can be large. Especially so when the number is controlled by external forces.

    Whilst hardware is cheap, for individuals as well as many companies that rely upon ISP or hosters for their hardware, the cost of purchasing (the use of) large enough boxes to handle peak loads, that sits idle 90% of the time is prohibitive. One only has to look to the slugishness of this site a few month ago before Pair kindly donated addition hardware resourses, to see that it isn't always a simple case of economics.

    Taking elementary steps to avoid wasting resources is far from "premature optimisation". Even when writing simple apps, understanding what costs and what doesn't is not "evil", more common sense.

    There is a compromise between bloat and unmaintainable, over-optimised code. The key to finding that compromise is understanding. Branding every request that mentions "efficient", "fast" or "use less" as premature optimisation is to deny that there is a problem. The barrier to understanding is the denial of the problem and the possibility of solutions.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

      I didn't say what you say I said.

      If the page is used twice a day by one person, it still doesn't matter. I've got pages that are used by 1 or 2 people twice a day tops, so I don't care how they work, beyond that they are correct.

      If he's actually looking at a situation with many hits, then it starts to matter - but I also said 'try it out and see'.

      --Bob Niederman, http://bob-n.com
Re: Re: Memory /speed questions
by liz (Monsignor) on Jul 30, 2003 at 07:47 UTC
    And if you really want to fine-tune your memory usage at the Perl level, there's Dan Sugalski's Devel::Size of course.

    Liz