SA Bugzilla – Bug 5880
MEMORY: Net::DNS "sec" module can use up 5 megs of ram per process needlessly
Last modified: 2019-06-24 15:17:09 UTC
./DNS ./DNS/SEC ./DNS/SEC/Private.pm ./DNS/Update.pm ./DNS/RR ./DNS/RR/NSEC.pm ./DNS/RR/DS.pm ./DNS/RR/SIG.pm ./DNS/RR/NXT.pm ./DNS/RR/RRSIG.pm ./DNS/RR/KEY.pm ./DNS/RR/DNSKEY.pm ./DNS/SEC.pm I usually create a sandbox for these files and unshift it into the @INC path. and just do package Net::DNS::Sec::Private; 1; So Net::DNS will just load stubs.
Mucking about with $INC might be a better option here. $INC{'DNS/SEC/Private.pm'} = 'stub'; $INC{'DNS/Update.pm'} = 'stub'; $INC{'DNS/RR/NSEC.pm'} = 'stub'; ... I'm not sure what is the best way to make this maintainable in the future though. The savings is pretty substantial however since there are a lots of dependency modules that no longer get uselessly loaded.
it might be worth taking it upstream to Net::DNS -- e.g. a parameter we can set in the Net::DNS namespace, $Net::DNS::SUPPORT_DNSSEC = 0. they already lazy-load and conditionally evaluate code based on the presence of Net::DNS::SEC module -- adding a boolean check to that would be relatively easy. BEGIN { $DNSSEC = eval { local $SIG{'__DIE__'} = 'DEFAULT'; require Net::DNS::SEC; 1 } ? 1 : 0; } (note that since it's a BEGIN block we can't use the nicer "parameter to constructor" idiom without some heavier code changes there though.) in my experience the Net::DNS maintainers have been quite good about responsiveness to patches....
Closing old stale bugs. This one looks very hacky and something upstream should do if needed.