Hi, While profiling CPU usage, I noticed that everytime tracker writes to a log file, it invokes localtime(3) to generate the timestamp. This is less than ideal, because localtime(3) is a relatively expensive function. The attached patch changes the behavior in tracker-log.c to invoke localtime(3) only once, during the invocation of tracker_log_init, and then use gettimeofday to update the time relative to the time returned by the initial localtime(3). Benchmarking these two approaches demonstrates that this new approach is 85.2% faster on an Intel Atom and 16.4% faster on an Intel Core 2 Duo. Benchmarking these two approaches in the context of log_output() demonstrates that with this new approach the function executes 41.4% faster on the Intel Atom and 14.5% faster on the Intel Core 2 Duo. While, mktime(3) could have been used to normalize the tm struct, the use of mktime(3) significantly subtracted from the performance improvement. Let me know what you guys think. Thanks. -- Jim Kukunas Intel Open Source Technology Center
Attachment:
log_output.patch
Description: Text document