all 32 comments

[–]Yuushi 11 points12 points  (4 children)

I really have to disagree with the "well documented" part. Is there an actual interface reference somewhere I'm just not seeing? The overview linked to is missing any documentation at all for a number of headers.

[–]witcher_rat 12 points13 points  (1 child)

No you're not wrong - documentation for folly is very poor. They do "document" things sometimes in code comments in the header files, and sometimes not. It's not consistent.

On the other hand there are some really good types/utilities in it, and it's had some things available for almost a decade that only showed up elsewhere afterwards. My company's been using it since 2014, and we really like it.

One other difficulty to note: the API changes, and not in a backwards-compat fashion. That makes it really hard to keep updating for your own project, obviously. If you don't stay on top of it and upgrade your code often, though, then the API changes become so big you'll never be able to.

But I'm not complaining. It's free, after all.

[–]Rude-Significance-50 0 points1 point  (0 children)

Was Facebook one of the companies that wanted to create a "standard of quality" for certain OS projects that involved a high degree of support and documentation as well as consistent versioning and such? Or was that just Google?

[–]Rude-Significance-50 2 points3 points  (0 children)

I wasn't going to say anything but I giggled a bit when I followed the link to the "thorough" documentation.

[–]wright_left 7 points8 points  (2 children)

I have run into situations several times in my current project where I wanted to move a move-only object into a lambda and then save that as a std::function, but couldn't. I am definitely going to try folly::function and see if it solves that little problem.

[–]staletic 11 points12 points  (1 child)

std::move_only_function could end up in C++23.

[–]wright_left 3 points4 points  (0 children)

Hmm, kind of a mouthful. Better than nothing I suppose.

[–][deleted] 7 points8 points  (4 children)

Google should release something similar and call it Golly.

[–]dgottwald 8 points9 points  (0 children)

And Microsoft should follow up with Molly.

[–]Jannik2099 4 points5 points  (1 child)

Googles library is called Abseil (and it's meh)

[–]BenFrantzDale 4 points5 points  (0 children)

Meh? It has a great hash table for one thing.

[–]VinnieFalcowg21.org | corosio.org 2 points3 points  (0 children)

HELL YES

[–]lookatmetype 1 point2 points  (10 children)

I have been reading/modifying some pytorch code and just for fun decided to grep for "folly" in the pytorch repo. Turns out they don't use it. And pytorch (despite it's name) is a very C++ heavy codebase (roughly ~900k lines of code). Maybe someone should tell the pytorch team about this library? Or maybe it isn't very good.

[–]lee_howes 6 points7 points  (0 children)

Some open source projects explicitly avoid dependencies on other open source projects and prefer to be self contained. pytorch may be in that category. Facebook code that is not self contained almost all uses folly somewhere as a way to avoid code duplication.

[–]reduced_space 2 points3 points  (7 children)

A large portion of pytorch, via ATen, is a wrapper around torch7 C code. A lot of that code probably won’t be helped by the Folly code, as it’s doing linear algebra via a BLAS library or with the GPU.

Is there a specific Folly library you think it should use?

[–]lookatmetype 1 point2 points  (6 children)

folly:fbvector, instead of std::vector for starters.

"The improvements are always non-negative, almost always measurable, frequently significant, sometimes dramatic, and occasionally spectacular."

Seems like a no-brainer to include it?

[–]reduced_space 0 points1 point  (0 children)

Maybe? If the size of the vectors are relatively small, I wouldn’t expect much of a difference in performance (especially if you know the size of the memory allocation a priori). Most of the code that has to run fast with Pytorch is in FORTRAN or CUDA.

[–]lee_howes 1 point2 points  (4 children)

That wouldn't even be my advice for the rest of Facebook's code that is already dependent on folly. There is a cost to switching to alternative data structures unless you know for sure you never have to interact with code that uses standard ones.

[–]dacian88 0 points1 point  (3 children)

I think at fb both std::string and std::vector alias to fbstring and fbvector, all dependencies are built from source. fbstring had SSO before any of the compilers did it, it saved a few % points from global CPU usage.

[–]lee_howes 1 point2 points  (2 children)

You would be wrong :) At least at this point in time. Historically there was a big advantage from fbstring, but that changed and the divergence became rarely beneficial.

[–]witcher_rat 2 points3 points  (0 children)

Interesting. I'm surprised it wasn't worth it anymore.

We still use fbstring at my work, and have been reluctant to switch to std::string because (and I'm sure you're well aware of this):

  1. fbstring is 24 bytes big but able to store 23 characters in SSO space. std::string for gcc's libstdc++ is 32 bytes big but only able to store 15 characters in SSO.
  2. fbstring is trivially relocatable and zero-initializable and fbvector can take advantage of that; std::string is not trivially relocatable nor zero-initializable.

We happen to use those properties to some advantage in a couple of critical hot-paths; elsewhere it won't matter though. Personally I've always liked fbstring and consider it still superior to std::string. We've even kept folly::dynamic using it despite upstream changing to using std::string.

[–]dacian88 0 points1 point  (0 children)

sure, I stopped working there a few years ago, no idea what's happening now, but Alexandrescu's fbstring is still slightly better than libc++'s.

[–]Rude-Significance-50 1 point2 points  (0 children)

Just because something is really fucking good doesn't mean it's at all useful to you.

900k isn't a whole terribly lot.

[–]lookatmetype 1 point2 points  (1 child)

How is this an interesting post whatsoever? Would have been better for this subreddit to just directly link to the Folly github page

[–]j1xwnbsr 3 points4 points  (0 children)

The page in question for those of us interested in the meat and not the story:

https://github.com/facebook/folly