144 points · by optimalsolver · 5y ago · 79 comments
Note of passing: https://www.facebook.com/groups/20296764839/posts/1015929527...
EASTL paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n227...
Partial list of Paul's programming credits: https://www.mobygames.com/developer/sheet/view/developerId,2...
I love this bit of the 1993 bio on Mobygames: "I do this computer work on the side as a hobby"
MS Hearts, wow!
- What stands out about it?
- Benchmarks?
- What platforms are supported?
- How is it differentiated today vs. 15 years ago? Qt wound up with its own 'standard library'-alike types mainly because the STL (and its implementations across platforms) were not really up to snuff when it started out. I suspect this may be similar.
- Does anyone have direct experience to share? :-)
Edit: Found some info at https://eastl.docsforge.com/master/faq/#info2-what-uses-are-... and benchmarks at https://eastl.docsforge.com/master/benchmarks/
Especially interesting for me as Linux dev: "[...] EASTL is significantly more efficient than Dinkumware STL, and Microsoft Windows STL [...] EASTL is roughly equal in efficiency to STLPort and GCC 3.x+ STL, though EASTL has some optimizations that these do not."
Edit: there's an extensive FAQ in the docs folder: https://github.com/electronicarts/EASTL/blob/master/doc/FAQ....
Imagine they wrote their own Javascript engine before V8 became really performant. That sort of thing.
Used it a few times for some medium-complexity stuff, here’s an open-source example: https://github.com/Const-me/vis_avs_dx/tree/master/avs_dx/Dx...
Works OK, and indeed faster than VC++ (I was using VS2017 at that time), especially in debug builds.
One interesting feature missing from the standard library is segmented_vector container. https://github.com/electronicarts/EASTL/blob/master/include/...
Those that prefer cars without seatbelts, or motorbikes without helmets, can #define them away.
It can be a bit annoying because all other libraries you link with must also be have this set the same.
- customizable allocators and alignment
- designed with turning off exceptions in mind
- performance improvements(especially map and list)
- portable between different C++ vendors
Quite appropriate to this subject are the talks from Mathieu Ropert.
Here is one of the latest ones,
"This Videogame Developer Used the STL and You'll Never Guess What Happened", ACCU21
std::vector: $5
std::string: $15
std::map: $30
std::unordered_map: $100
I'm too cheap to pay triple the price for a little bit of convenience.
std::vector<char> Derp;
Derp.resize(sizeof StringLiteral);
memcpy(Derp.data(), StringLiteral, sizeof StringLiteral);
+ in-template purchases for every specialization of std::hash for user type.
https://eastl.docsforge.com/master/design/#listsize-is-on
I am surprised compilers don't magically optimize the code and remove the size-remembering variable if it is not needed.
the problem is that technically anyone can come and do
auto lib = dlopen("my_lib.so", 0);
auto sym = dlsym(lib, "_ZNKSt7__cxx114listIiSaIiEE4sizeEv"); // std::list<int>::size()
auto func = static_cast<void(*)(std::list<int>*)>(sym);
std::list<int> some_local_list = ...;
(*func)(some_local_list);
and that is expected to not crash - template symbols are generally part of your shared library API (at least that's been the default, however bad it is, on Linux, for a very long time).
If compilers were optimizing the layout of individual list instances, then the above wouldn't work anymore (unless the compiler would inline / create new symbols for each individual cases in your code which would make the object sizes go through the roof).The only way something somewhat similar to what you posted could possibly work would be to have some_local_list allocated/constructed dynamically from the same shared object that contains the the member function and to expose the member function using extern "C".
For example something like:
auto some_local_list = create_list(...);
list_size(some_local_list);
Where create_list is a function loaded from the same dlopen and returns a dynamically allocated and opaque handle to a list, and list_size is also a function loaded from dlopen that is exported using extern "C".With this approach it's certainly possible for a compiler to optimize out unused member variables. Any other approach is undefined behavior and may or may not work.
"in principle" goes away as soon as we use dlopen, as it implies a lot of things on the way C++ will be supported on that given platform ; no one cares about C++ in a vacuum.
In practice, different .dll / .so / .dylib communicate through C++ APIs all the time ; all relevant platforms have to support that at some level (which can sometimes cause strong headaches, for sure: https://www.codesynthesis.com/~boris/blog/2010/01/18/dll-exp... ).
Also, just because something is x64, doesn't mean it's standard library is up to snuff, or that it has the same features. You might be using a 5 year old compiler with a standard library to match it.
EASTL provided a bunch of value that the standard STL would not. The biggest benefit was a unified implementation across all platforms. Standard library STLs all had their own idiosyncrasies and code that worked on one platform might not compile, or worse, have a bug on another.
At the time, EASTL was equal or higher quality than standard implementations. Performance was better, code quality was better, and it broke from the standard in some key ways that were important for performance, and it had some key upgrades that allowed usage patterns and data structures that the standard STL simply didn't allow:
Vectors supported "trivial relocation" before the existence of move constructors. While move constructors have ameliorated the problem, I argue that feature is still missing from c++. Please support P1144! http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1144r5....
Intrusive containers (in particular, intrusive linked lists in eastl::intrusive_list) embed the container overhead into objects themselves. This allows non-movable objects to be stored in these lists without requiring an extra pointer dereference on access. It also lets you convert an object reference into an iterator over the list that contains it. There are tons of uses for this. It also allows polymorphic lists (e.g. intrusive_list<BaseClass> that actually holds instances of various subclasses, again without an extra pointer dereference)
If you want more information, EASTL's lead programmer Paul Pedriana (rip) goes into detail in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n227...
https://www.youtube.com/watch?v=vElZc6zSIXM
Or pretty much any other by Chandler to understand why the STL sucks and why you should write better datastructures for your own use cases.
These assumptions are often wrong. It's possible they were not wrong when the STL was first conceived, but we don't care about that because we're writing programs now, not then.
For example the STL unordered_map thinks your hash map has buckets. After all, if you learned how to make such a data structure in a typical college course in like 1995 the hash map had buckets. So the mandatory API for the STL's unordered_map has buckets like in that college course.
But today in many cases you don't want buckets, you've got a single unbucketed structure. How do these APIs work with your better structure? They don't. The STL is incompatible with your better structure.
2. The STL bakes in a bunch of assumptions about how C++ works.
Those assumptions were undoubtedly correct when the STL was first conceived, but since then there have been major changes to the language and all it can do is bolt on more and more, and more boilerplate to try to cope.
Take emplace(). This looks like it's a better choice in a bunch of cases than say, insert() and then you dig into your STL implementation and you discover it had no choice but to construct your expensive object and then throw it away when it wasn't needed just as you might have with insert(). That's just how the class is defined, too bad.
If EASTL is in fact just an STL then it might be no better than a modern STL you got with your compiler. But some people choose to have something better instead of the STL. Abseil's Swiss Tables for example offer a faster Unordered Map, it's just that it isn't, and can't be, a std::unordered_map