   Linux server - custom vs Boost
  Boost seems incur a large overhead for basic networking and threading that doesn't seem to have a "win" attached to it.Anyone have thoughts on why I should NOT shelve Boost since I've committed to a single platform?I've rolled by own before so I do know what's involved if I don't use Boost, but I have not used Boost before so I'm not really sure what I'd be gaining, if anything.  RAD?Thanks in advance!-Szii   
  If you haven't used it before, how do you know it incurs a large overhead?AFAIK, it's usually pretty efficient because all of it's template-code is evaluated at compile time.The benefit of using boost threading/communication classes is platform independence. If you only care about linux, then this may not be a benefit for you.   ;  Anytime your wrap/abstract code out you're going to take a hit.  I just don't know exactly how big that hit is.  However...Q: How many large-scale games use Boost vs rolling-their-own?If the hit was extremely trivial then Boost would be the defacto everywhere except the top 1%.Now, I'm not saying I'm going to be in the top 1%, but Boost appears REALLY annoying to use (far beyond than just the STL.)What I'm hoping to find is that there are multiple unseen benefits to Boost that are not instantly obvious (at least to my obtuse-self.)  If so I will definitely learn/use Boost.  Yes, I know I could proto something and run that, but it doesn't give the same indicators of performance that someone who's already been there and has a larger system would be able to confer.Thank you for the insight and taking the time to reply!-Szii   ;Quote:Boost seems incur a large overhead for basic networking and threading that doesn't seem to have a "win" attached to it.It does? Granted, the syntax gets gnarly and some compile errors are longer than many novels, but mostly it's acceptable.Boost::thread is wrapper across OS calls. It has no overhead as such, and will be used as standard C++ threading. So the "win" is that it's effectively part of standard library. There is no overhead involved. Alternative is obviously pthreads.Boost::asio is, again, wrapper over IOCP, AIO or kqueue. The "win" is that its interface, despite being namespace bloated, is quite simple and straight-forward and it also solves the missing features of async networking, such as timers and timeouts.The overhead of asio is not measurable - IOCP server takes 1% CPU for networking, asio version takes 1% CPU for networking (at 100% 100Mbit utilization, and it's been a long time since I benchmarked this).The functional alternative is ACE... Not sure if it's an improvement.That is, if you need asynchronous networking. If blocking/non-blocking is enough, then just using sockets directly will probably work well enough.Forum FAQ has several other alternatives listed as well.Quote:Anytime your wrap/abstract code out you're going to take a hit.Not necessarily, especially not in C++, where compiler is required to not make you pay for what you don't use. I've encountered a case where wrapped code produced better compile time optimizations (numeric operations on integers) than direct calculations, despite being wrapped by dozens of templated classes. Obscure case, but still.Quote:Q: How many large-scale games use Boost vs rolling-their-own?Are you a large-scale developer with large-scale budget, large-scale team and large-scale market?Quote:What I'm hoping to find is that there are multiple unseen benefits to Boost that are not instantly obvious Perhaps that it's written by experts, peer-reviewed, actively maintained and used extensively in practice and has been for years.Boost libraries however are generic. So if you really have specialized needs, some of its solutions will not be suitable. Lack of exceptions, compilers that choke on templates, heavy memory constraints, developers unfamiliar with more "advanced" C++ concepts or perhaps toolchain not well suited for template-heavy code, then it might not be suitable choice.   ;Quote:It does? Granted, the syntax gets gnarly and some compile errors are longer than many novels, but mostly it's acceptable.Thanks for the info - good stuff.Quote:Quote:Anytime your wrap/abstract code out you're going to take a hit.Not necessarily, especially not in C++, where compiler is required to not make you pay for what you don't use. I've encountered a case where wrapped code produced better compile time optimizations (numeric operations on integers) than direct calculations, despite being wrapped by dozens of templated classes. Obscure case, but still.I don't worry much about compile-times but I don't know the internals of Boost.  Anything can look good from the outside but be complete crap internally. (re: MFC)  And yes, I'm still gun-shy after all of these years which is why I'm trying to figure out the real cost of Boost, and if there's anything "hidden" that people have come across since templates themselves aren't bad.Quote:Quote:Q: How many large-scale games use Boost vs rolling-their-own?Are you a large-scale developer with large-scale budget, large-scale team and large-scale market?All snarkiness aside, does it matter?  This is code, not rocket science and as mentioned before I have done it before (though, I cannot reuse it due to licensing restrictions.)  Networking/threading isn't hard, you just have to be accurate/precise.  Would I like to alleviate dev time and testing?  Of course.Quote:Quote:What I'm hoping to find is that there are multiple unseen benefits to Boost that are not instantly obvious Perhaps that it's written by experts, peer-reviewed, actively maintained and used extensively in practice and has been for years.Lot of people still use VB, too.  Some even use it for servers.  Really.  Just because it's available and someone's doing it doesn't mean it's a good fit for every project.  In this case, I just wanted to know if there's more to it than cross platform.Hey, thank you both for replying!  I'm going to go with Boost for this one.Rock on!-Szii   ;  Previous posters have brought up most of the primary benefits of boost, but I feel that one more thing deserves a mention here: Boost "just works(tm)". Why waste your time writing and debugging code based on error-prone C APIs such as pthread and epoll when Boost already provides high-quality, proven and working implementations?Of course, like someone said, there are cases where using Boost may not be appropriate. But for a game server, where there should be no major constraints in terms of memory or compiler quality, is see no reason why not to use it.In the end it comes down to what you are comfortable with. Boost will save you time, but writing the low-level code yourself is both interesting and a good learning experience. But if you do, be prepared to spend more time on it.   ;  When talking about overhead, code (executable) size may be just as important as other things, like call stack depth etc. If your executable is big, it will take longer to start, it will take longer to transmit/download/install, and it will put a lot more pressure on disk cache as well as I-cache. The I-cache pressure is quite insidious, because any single micro-benchmark is unlikely to find a problem, but the aggregate of all the separate, large template expansions end up causing lots of I-cache eviction.As an aside: This is one reason why some bytecode interpreters are faster than you'd initially think. They just need to keep the small interpreter kernel in I-cache (typically it will fit in L1, with space to spare), and the code execution sequence comes out of D-cache (which is often larger than I-cache, too).I agree: Boost Just Works (tm). When the design choices they made make sense, it's a great library to use. When the design choices they made do not match your project, some parts are still useful as building blocks. However, if you find that Boost is a poor match for your needs, there is no law saying you Must Use Boost. Good engineering means finding the optimal trade-offs for the problem at hand.;  Good point to remember to optimize later ... always tempting to over optimize from the beginning and work on stuff which isn't a bottleneck in the first place and more gains could be had in other places.Code.Profile.Tune.Thanks!-Szii