<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:14px">I'd suggest to start with you just look at moving the libmagic check after<br></span><span style="font-size:14px">the filesize checks, so you don't need to get into whether libmagic or<br></span><span style="font-size:14px">the database check is cheaper on average.</span></blockquote><div><br></div><div>hi, Olly, I have moved the libmagic check after the filesize check directly,</div><div><br></div><div><a href="https://github.com/caiyulun/xapian/commit/3a97d9ee5397fa900a473aa9b3d8eeb720177a4e">https://github.com/caiyulun/xapian/commit/3a97d9ee5397fa900a473aa9b3d8eeb720177a4e</a> </div><div><br></div><div>can you provide your comments on it and give some advice about the next steps?</div><div><br></div><div>I think it is hard to say which is cheaper between the libmagic and database check</div><div><br></div><div>Thanks</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-04-21 13:37 GMT+08:00 Olly Betts <span dir="ltr"><<a href="mailto:olly@survex.com" target="_blank">olly@survex.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri, Apr 21, 2017 at 01:52:38AM +0800, YuLun Cai wrote:<br>
> I'm working on the ticket #743 omindex: delay libmagic checks<br>
</span>> <<a href="https://trac.xapian.org/ticket/743" rel="noreferrer" target="_blank">https://trac.xapian.org/<wbr>ticket/743</a>>. As the ticket's<br>
<span class="">> Description mention, the call to libmagic is expensive than call the stat,<br>
> so we can check the size by call the stat to get size before call<br>
> libmagic to get a mime type.<br>
<br>
</span>Yes.<br>
<span class=""><br>
> But how about the timestamps check? since timestamps check need to iterate<br>
> the DB to check if the file has been indexed and hasn't changed(in<br>
> `index_check_existing` function in omega\index_file.cc), so it is expensive<br>
> too. Should we call the libmagic before or after the timestamps, or do we<br>
> have another way to check the timestamps?<br>
<br>
</span>We also have an upper bound on the newest timestamp in the database at the<br>
start of the run, so we can often avoid this check for new files (at least<br>
if they were created since the end of the previous index run).<br>
<br>
But that just quickly tells us "yes" for such files (at least on the basis of<br>
timestamp) so we'd need to check them with libmagic anyway.  To get a "no"<br>
based on timestamp we need to check against the database.<br>
<br>
I'd suggest to start with you just look at moving the libmagic check after<br>
the filesize checks, so you don't need to get into whether libmagic or<br>
the database check is cheaper on average.<br>
<span class=""><br>
> What's more, how should we write tests to prove the omindex works<br>
> correctly, to generate some practical directories and use omindex to index<br>
> it then check the things in DB?<br>
<br>
</span>We don't (sadly) have any tests of omindex behaviour currently, but having<br>
some would be great.<br>
<br>
You'd need to work out what cases you're aiming to test and then script up<br>
suitable changes to the directory between the omindex runs.<br>
<br>
Cheers,<br>
    Olly<br>
</blockquote></div><br></div>