update-apt-xapian-index is truncated and shown as update-apt-xapi in top tool. This process is responsible for maintaining an index of packages to speed up search on Synaptic and is scheduled as a cron job (/etc/cron.weekly).
This is the cron job, triggering the process:
#!/bin/sh
CMD=/usr/sbin/update-apt-xapian-index
IONICE=/usr/bin/ionice
# Rebuild the index
if [ -x $CMD ]
then
if [ -x $IONICE ]
then
nice $IONICE -c3 $CMD --quiet
else
nice $CMD --quiet
fi
fi
Edit the lines to show the following:
#!/bin/sh
CMD=/usr/sbin/update-apt-xapian-index
IONICE=/usr/bin/ionice
# Rebuild the index
if [ -x $CMD ]
then
if [ -x $IONICE ]
then
nice -n 19 $IONICE -c 3 $CMD --update --quiet
else
nice -n 19 $CMD --update --quiet
fi
fi
The modification will help reduce CPU usage. -n 19 option gives least favorable scheduling priority. --update option causes the process to update the index instead of rebuilding it every time.



Many thanks for this - my machine crawls whilst this job runs.
ReplyDeleteThanks also for including in the text the
"top" report string as google food. "update-apt-xapi" is a bit misleading to say the least if one doesn't know about xapian-index.
Glad to know that you find this useful.
ReplyDeleteThank you very much. This information was usefull for me.
ReplyDeleteBest regards.
Guillermo from Argentina.
Thanks Guillermo.
ReplyDeleteThank you; I was running into the same high CPU usage issue with Mint. It already had changed the nice values to 19, but I added the --update flags. I hope to see positive results from that change.
ReplyDeleteThanks for the feedback John!
ReplyDeleteThank for sharing. I also hope to see positive result.
ReplyDeleteThank you :)
ReplyDeleteUPDATE: Looks like Ubuntu is including these changes in by default now. You need not worry about it if you are updating!
ReplyDelete@Sap Nwnewbie: as a user of Ubuntu 11.10 and 12.04 I can tell the problem is not solved yet.
ReplyDeleteThey added the "-n 19" part of the correction, but not the "--update"...
LAST MINUTE: you may also need to add --update option to update-apt-xapian-index in /etc/cron.daily/apt
ReplyDeletenice ionice -c 3 update-apt-xapian-index --update -q $xapian_extra_args
This explain why update-apt-xapian-index is not only having high CPU usage on Sunday as it should with cron.weekly
@Alain. Thanks for the additional input.
ReplyDelete