wesley tanaka

Low Memory Event Module

The event module uses a lot of memory, at least with stock PHP, and thus takes a long time to load on every page, even if it's not being used on that page.

Splitting the module into separate files which are loaded on demand still saves about 1/2 MB of memory per page load.

Installation

cd sites/all/modules/event/
wget -O - http://wtanaka.com/system/files/event-mem-5.x-1.0.patch.bz2 | bzcat | patch -p4

Notes

This is what I used to split event module 5.x-1.0. You'll probably want to re-inline some of the hooks that get called on every page view and move the last two includes to only happen when they need to.

#!/bin/sh
FILE=event.module
grep '^function' $FILE | sed -e 's/^function \([^(]*\)(.*/\1/g' \
| grep -v '^event_menu$' | grep -v '^event_help$' > /tmp/flist
for i in `cat /tmp/flist`; do
echo '<?php' > ${i}.inc.php
sed -e "/^function $i\>/,/^}/ !d" -e 's/^function /function real_/' $FILE >> ${i}.inc.php
ex $FILE <<EOF
/function ${i}\>
y

i
include_once(EVENT_PATH.'/${i}.inc.php');
.
put
s/^function / return real_/
s/&\\\$/$/g
s/[ ]*=[^,)]*//g
s/)[ ]*{[ ]*/);/
a
}
.

,/^}/d
w
EOF
done
rm /tmp/flist

sed -i -e '/\/\*\*/,/\*\// d' $FILE
AttachmentSize
event-mem-5.x-1.0.patch.bz222.12 KB
Syndicate content
by Wesley Tanaka