Hi all, I find the current building system of Android uses /usr/bin/find heavily, iotop[1] shows /usr/bin/find consumes 98% disk I/O bandwidth, the heavy I/O load makes virtual terminal hang frequently (We login a central Ubuntu server with ssh), it's very very annoying, so I write this little wrapper script to cache output of /usr/bin/find.
Simple usage is shown below, see the script itself for detailed description. ...save the attachment as $HOME/bin/find... chmod u+x $HOME/bin/find cd top-dir-of-android-code export PATH=$HOME/bin:$PATH . build/envsetup.sh lunch 1 make Below is output of `time make` that just checks all targets: ==================== cached find: real 0m13.958s user 0m10.749s sys 0m4.124s original /usr/bin/find: real 1m14.578s user 0m8.773s sys 0m2.368s ==================== I hope this script is useful for you. [1] iotop: http://guichaz.free.fr/iotop/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---
#!/bin/sh # # Purpose: # cache result of find command to avoid heavy load on the disk I/O. # # Usage: # change your PATH temporarily to use find instead of /usr/bin/find, # delete corresponding file under $CACHE if you add or delete some # files. # # You can change REAL_COMMAND below to cache output of other commands, # this script is generalized like Perl's Memoize module: # http://search.cpan.org/~mjd/Memoize-1.01/Memoize.pm # # Author: # yubao....@gmail.com # # License: # BSDL # # Version: # 0.3 # # ChangeLog: # 2009-03-17 Liu Yubao # * initial version, v0.1 # * don't cache output of find if it goes wrong # * use ed instead of sed, suggested by inva...@newsmth # * record return value, keep cache (conflict with second change above), # v0.2 # # 2009-03-18 Liu Yubao # * separate output, command and return value into two files # * take $0 into account when calculate MD5 digest, v0.3 REAL_COMMAND=/usr/bin/find CACHE="$HOME/.find-cache" cwd="$PWD" args="$*" md5sum=`echo "$cwd $0 $args" | md5sum | cut -c -32` file="$CACHE/$md5sum" [ -e "$CACHE" ] || mkdir -p "$CACHE" if [ -f "$file" ]; then cat "$file" read < "$file.cmd" exit $REPLY else # { $REAL_COMMAND "$@" || rm "$file"; } | tee "$file" { $REAL_COMMAND "$@" ; retval=$?; } | tee "$file" { echo $retval echo "CWD=$cwd CMD=$0 $args" } > "$file.cmd" fi