This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Is updatedb using incremental update of the database?


Giorgos Tzampanakis sent the following at Friday, October 29, 2010 12:27 PM
>I created a database by running updatedb, and then i re-ran updatedb
>and it took roughly the same amount of time. After a short discussion
>in #linux at freenode, I think that this is because the cygwin updatedb
>does not support incremental update of the database. Is it so? Is there
>a way to get an incremental updatedb working on cygwin?

Please not that I'm not an expert in the find utilities, so part or all of
the following may be incorrect.

updatedb is just a script that seems to be provided by Gnu.  As provided,
it does not seem to have an incremental option.  Look inside and also see
<http://www.gnu.org/software/findutils/manual/html_mono/find.html#Invoking-updatedb>

And how would an incremental option work?  The only way to see if a file
is or isn't there is looking for it.  Sounds like a full index to me.

My impression is that the slow part of running updatedb is the find
command.  I find that cmd.exe is faster so I have rewritten the script
to list files with a variation of the following.

for D in list_of_directories_to_be_indexed
do
  "$(cygpath -u "${COMSPEC}")" /c dir /s /b /a: /o:n "$(cygpath -w "$D")"
done | \
  tr -s '\r\n' '\n' | \
  sed	-e 's,^[oO]:,/o,' \
	-e '/^$/d' \
	-e 's,/\+,/,g' \
	-e 's,\\,/,g' | \
  sort -u \
  /usr/lib/frcode \
  > /var/updated.tmp
chmod 666 /var/updatedb.tmp
mv /var/updated.tmp /var/locatedb

Note that one may have to make changes depending on the detail of one's
Cygwin installation, e.g., cygdrive.

How to adapt that script to the case where some directories rarely change
so that the output of cmd.exe is cached is left as an exercise for the
reader.

One might speed up the scan by running cmd on different directories in
different processes that are run simultaneously in the background.  The
outputs are then combined after they all finished.  This, too, is left
as an exercise for the reader.

Again, the above is adapted from what works for me.  YMMV.  And I'm just
a guy who writes scripts that sometimes work for me, not an expert.  So
believe anyone who says that I've got it wrong.

Good luck.

- Barry
  Disclaimer: Statements made herein are not made on behalf of NIAID.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]