Re: git: 8bae22bbbe65 - main - fusefs: prefer new/delete over malloc/free

From: Warner Losh <imp_at_bsdimp.com>
Date: Fri, 19 Jan 2024 18:19:47 UTC
On Fri, Jan 19, 2024, 8:39 AM Alan Somers <asomers@freebsd.org> wrote:

> On Fri, Jan 19, 2024 at 6:56 AM Alan Somers <asomers@freebsd.org> wrote:
> >
> > On Thu, Jan 18, 2024 at 10:32 PM Enji Cooper <yaneurabeya@gmail.com>
> wrote:
> > >
> > >
> > > > On Jan 17, 2024, at 2:50 PM, Alan Somers <asomers@FreeBSD.org>
> wrote:
> > > >
> > > > The branch main has been updated by asomers:
> > > >
> > > > URL:
> https://cgit.FreeBSD.org/src/commit/?id=8bae22bbbe6571da9259e0d43ffa8a56f4b3e171
> > > >
> > > > commit 8bae22bbbe6571da9259e0d43ffa8a56f4b3e171
> > > > Author:     Alan Somers <asomers@FreeBSD.org>
> > > > AuthorDate: 2024-01-15 23:49:47 +0000
> > > > Commit:     Alan Somers <asomers@FreeBSD.org>
> > > > CommitDate: 2024-01-17 22:49:41 +0000
> > > >
> > > >    fusefs: prefer new/delete over malloc/free
> > > >
> > > >    MFC after:      2 weeks
> > > >    Reviewed by:    kib
> > > >    Differential Revision: https://reviews.freebsd.org/D43464
> > >
> > > Why not use smart pointers instead?
> > > -Enji
> >
> > Only because this stuff all evolved from C code.  Smart pointers would
> > certainly work.
>
> Actually, TBH it's because I'm not real great with C++.  It's a
> difficult language, and after 2016 I stopped even trying to improve my
> C++ skills.  Instead, I've been focusing on Rust.  Even when I wrote
> these tests in 2019, I strongly considered using Rust instead of C++.
> In the end, the only thing that forced me to use C++ is because I
> wanted them to live in the base system, rather than in ports.
>
> I still dream about the day when Rust is allowed in the base system.
> If it were, then in addition to these tests, I would've converted
> gstat to Rust (rather than add sysutils/gstat-rs to ports), added the
> nfs-exporter (instead of putting it in net-mgmt/nfs-exporter), added a
> ctl-exporter (which is impossible to do in ports, so I had to do that
> one in C), and converted tools/regression/fsx in place (instead of
> putting in devel/fsx-rs).  Maybe a couple of other things, too.  Like
> ztop, or the geom-exporter that I have half-written.  I've also been
> tempted to rewrite zfsd in Rust.
>
> Alas, I sense that there is little appetite for bringing Rust into contrib.
>

I'd love there to be more tests written.

One of the problems (one of many) with the tests is they are build during
buildworld. This constrains them a bit too much, imho. While we can add
a bunch of tests that are written in interpreted languages like python, perl
or pdksh, it's harder to add one written in an alternative language that's
then compiled. Sometimes I think we should have a separate buildtests
installtests which assume a post-installworld environment. That would let
us build go, rust, etc tests. Though managing the crates, etc for the build
might prove to be an interesting, though ports manage fairly well with
carefully
constructed packages.

Rust is still evolving quickly relative to C. While C++ is also, it's not
widely
used in the tree so that evolution doesn't matter so much (though devd
likely needs a full re-write)

For rust to be considered in base, the community of developers likely
would need to see visible success stories. While the ports that do
the testing you mentioned are a good start, I'm of the opinion that
having in-tree rust test cases would be helpful. Though there's no
rust integration for kyua / ATF right now. I'd love to find some way to
make this happen, possibly with the requirement that pkg install rust
be done prior to the build, to show it's possible and to raise awareness
of rust's viability and to shake out the inevitable growing pains that
this will necessarily case. Tests are a good place to start since
we already have a high burden on the users of the tests in terms of
packages installed. We could have an opt-in set of rust tests that
would fail if you didn't have the right ports installed (which we could
encode into a metaport to keep it easy).

But rust, itself, in the base has a lot of logistical issues since it isn't
quite supported in llvm out of the box (I see john's note just now touching
on this as well). But to put up with the logistical issues, there needs to
be clearly demonstrated wins in our environment first, imho. I really,
though, would be concerned if this means we go from 2 llvm builds to 4.

Warner

>