<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 19, 2019 at 10:46 AM Augie Fackler <<a href="mailto:raf@durin42.com">raf@durin42.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Feb 15, 2019 at 02:39:44PM -0500, Valentin Gatien-Baron wrote:<br>
> Hello,<br>
><br>
> I wrote a fraction of hg status in rust, just the minimum needed to<br>
> compare current revision and working copy with few of the flags and<br>
> config settings supported. As you can imagine, the goal was better<br>
> performance.  Before trying to upstream bits of this, I figured I'd<br>
> check there's interest for this change in particular, or this kind<br>
> of changes in general (I suspect rust would bring significant<br>
> improvements to hg cat or hg files). The rest of this mail is more<br>
> details.<br>
<br>
This sounds _very_ promising and I'd love to see what you've got!<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Cool!</div></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Seeing my mail again, it's perhaps not clearly said that what I have and what I timed below is a fully rust exe that implements a fraction of hg status, not a change to python hg that uses big chunks of rust some fraction of the time. Though it seems that upstreaming would take the latter approach, at least to start with.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><span style="font-family:Arial,Helvetica,sans-serif"> </span><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
><br>
> While the implementation doesn't handle every uncommon situation right<br>
> and could use some serious cleanup, it's an interesting performance<br>
> improvement. In a repository with 100k tracked files and 500k ignored<br>
> files, in the best case and measuring on a good machine:<br>
><br>
> - hg-rs st takes ~50ms<br>
> - hg-rs st -mard takes ~14ms<br>
> - hg-rs st -u takes ~39ms<br>
><br>
> By contrast, hg+chg+fsmonitor's best case is 110ms regardless of<br>
> flags. Without fsmonitor, we're talking about 2.4s for hg st or hg st<br>
> -u, and 400ms for hg st -mard. As a baseline, hg st --syntax-error<br>
> takes 12ms.<br>
<br>
Fascinating! Are you using re2 or Python's built-in re?<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Definitely using re2. If I disable re2, the full status goes from 2.4s to 5.7s. I didn't say how the rust implementation differs from the python version, but using rust+re2 is not enough to get to 40ms for finding unknown files. In addition to optimizations to the hgignore handling (mostly special treatment of globs that can match exactly one file), and parallelism, and not pointlessly lstat'ing untracked files in filesystems that provide the filetype in readdir, there's a cache that holds a list of "this directory is known to have no untracked files assuming it has this timestamp, and the hgignore is bla and the dirstate is bla", which usually shortcuts the listing of untracked files in most directories, and thus shortcuts applying the hgignore on such files. </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Though even when the cache fails to help, like when the hgignore changes, rust status takes 300ms (and it's quite plausible there's room for improvement here, I stopped optimizing when it felt like a good enough replacement).</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
><br>
> A ratio of x2 compared with fsmonitor+chg is nice, but while neither<br>
> best case is what you get all the time, fsmonitor degrades pretty<br>
> badly, oftentimes in hard to understand ways, making for an<br>
> unpredictable experience that is frequently bad.<br>
> Say you change the hgignore, the rust version will take 300ms, the<br>
> fsmonitor version will take 4.4s (I think 2s timeout + 2.4s regular<br>
> status).<br>
> Say you remove a directory at the root of the repository, 50ms rust<br>
> vs 4.4s fsmonitor.<br>
> Say you haven't used a particular share in some time, you may well see<br>
> 1s rust vs 4.4s fsmonitor.<br>
><br>
> So I think there's a lot of value in having status without fsmonitor<br>
> going much faster:<br>
> - increase significantly the scale at which fsmonitor is needed<br>
> - improve the bad cases of fsmonitor (or even the fast path depending<br>
> on how things are made to work together)<br>
><br>
> Regards,<br>
><br>
> Valentin Gatien-Baron<br>
<br>
> _______________________________________________<br>
> Mercurial-devel mailing list<br>
> <a href="mailto:Mercurial-devel@mercurial-scm.org" target="_blank">Mercurial-devel@mercurial-scm.org</a><br>
> <a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel</a><br>
</blockquote></div></div>