At 1/28/01 2:32 PM, Josh Levine wrote:
>Well, I found out from my web host why the new versions of the OpenSRS
>scripts had been dying intermittantly with 500 errors - it was because
>their reaper had been killing it for using 14 MB of RAM. I am assuming
>this is because of the RACE code; any news on how the version without
>the RACE code is coming along (or ideas on how to use memory more
>efficiently)?
I can't guarantee this will work, but I've done the following. I replaced
the entire "lib/RACE_conf.pl" file in version 2.3 -- which is normally a
700K file that just fills in tons of variables -- with this:
----------------
#!/usr/bin/perl
#RACE Configuration
use vars qw(%FORBIDDENCHAR %CASEFOLDING $RACEPrefix %ALLOWEDCHAR);
use strict;
#
# Set the leader for the domain name.
#
$RACEPrefix = "bq--";
%FORBIDDENCHAR = (
);
%CASEFOLDING = (
);
%ALLOWEDCHAR = (
);
----------------
That's it -- I simply removed the contents of all the variables. This
works just fine with ASCII domain names. The net result on my machine is
that the scripts run about 2 seconds faster and use much less memory.
The reason this works without causing problems is that:
a) %FORBIDDENCHAR is never used (it's leftover code-in-progress that's
commented out, as you can see by looking at RACE.pm). Filling that huge
unused variable takes 11,000 lines of perl, wasting a couple of megabytes
of memory and tenths of a second for nothing.
b) the only place the other two variables are used is (directly or
indirectly) in RACEEncode of RACE.pm, and then they're only used if the
RACEAllAsciiCharacters check fails. As long as you're only offering ASCII
domains, this will be the case.
If you just delete these last two variables, you'll need to prevent
people from choosing other encodings anywhere. It may also be a good idea
to add an error to RACEEncode if it gets past the RACEAllAsciiCharacters
check in case you miss one.
The better fix for this that will work both with RACE domains and without
is to not load megabytes of variables unless it's required -- that is, if
the RACEAllAsciiCharacters check fails.
Also, is a hash of 40,000 variables really the best way to handle
%ALLOWEDCHAR? Since the vast majority of these are in contiguous ranges
it would be better to write a function that can do it, perhaps using a
hash for the few exceptions to some general rules.
--
Robert L Mathews, Tiger Technologies