• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
mrheisenberg

Does using libraries impair compiler optimization?

7 posts in this topic

Is there any place where it is explained how(if it actually does) does using a pre-compiled engine impair inter-procedural optimization?I mean to do that,the compiler needs the entire source code intact,right?So it's logical that using DLL's will impair optimization even more.Correct me if I'm wrong please.

0

Share this post


Link to post
Share on other sites
With link time code generation a compiler/linker like recent versions of MSVC can inline code from a static library. Inlining code from a DLL is something a linker generally won't do, different computers may have different versions of the DLLs or DLLs may be replaced with patched versions with bug fixes.
0

Share this post


Link to post
Share on other sites
I wouldn't worry about micro-optimizing by avoiding the use of external libraries. Even if it was slightly slower, you shouldn't worry about that when designing your program. When dealing with performance you want to choose efficient algorithms from the beginning, but don't worry too much about having the fastest algorithm possible. Just pick one that will have reasonable running time and, possibly more importantly, is simple to implement. If your code is designed well you should be able to easily change the algorithm later you find you need a faster one. When choosing what algorithm is faster, the most important factor is how well is scales meaning how will it handle 1, 10, 100, 1000, ect... number of items to proccess. This is known as an algorithm's complexity class.

Once you have your code working and if you find it isn't running as fast as you need it to. Then you profile the code. Find out where your program spends most of its time and decide how to speed that up. This may involve changing the algorithm you used. Change the way memory is used an the amount used to reduce cache misses. If you find there is a lot of time spent in a single piece of code, you may find ways to call that code less to reduce the amount of work done. Micro optimizing pieces of code to try to get the most per clock cycle or reduce the number of clock cycles will only make a noticeable difference if that code being optimized is being executed very frequently in the code.

So my advice to you. Don't worry about the speed impact of using a dynamic library. Write your code in a way that makes sense and is clean and easy to manage. Once you are done, then you optimize if needed. If you are worried about optimizing things too early you may find your project harder to manage and things may end up being more obscure. This means it takes longer for your project to be done and there will likely be more bugs and in the end the optimizations may have not made any significant difference to how fast the code runs anyway. To sum things up your time is more precious than CPU time.
2

Share this post


Link to post
Share on other sites

Any optimization you gain is not worth the effort. Assume (correctly) that each component (DLL) is built in release mode with the proper optimizations. This is all you really need, even the most demanding games approach things in this fashion.

0

Share this post


Link to post
Share on other sites

I personally believe that developers, especially programmers need to pick a side of the fence and stick to it.  If your making the engine yourself then you would want to consider and discover the most optimized and best performance oriented methods of doing everything yourself (outside of the DirectX / OpenGL hardware level API).  At this level you should focus more on building and benchmarking the engine itself and not so much on building a game (as it would distract you from making a good engine).

 

On the flip side of this same conversation if you are developing a game stop worrying so much about optimization of the engine itself and just learn to use it as it was intended.  The more time you worry about extending, porting, and otherwise trying to improve the engine itself the more your game design hurts for it.  You should be focusing more on understanding how the engine works and how you should use it properly as according to the documentation and the "proper" techniques as set forth by the engine coding team.  (Just do it like they tell you for optimal performance and your good).

 

But on to the actual question I have to agree with AAA on this one.  The micro optimizations and minor performance mods that may come from tuning your compilation are negligible at best.  The only worth while optimizations are when you optimize your code to specific hardware requirements which in turn drastically limit your potential audiences.  Most C++ compilers come ready to compile to the best possible cross hardware optimized versions as is and your not going to get much better performance by altering what the compiler is trying to do by it's default builds.

 

If you want noticeable gains inside your game you want to focus more on YOUR high level code and design.  Run tests and benchmarks and optimize your memory usage, disk read, caching and use event based logic triggers to minimize iterations of idle nodes and objects.  In a little more plain English, focus more on making your logic only calculate necessary snippets, limit the amount of stuff in ram and use pointers whenever possible, use dynamic memory and release when your done, cache things from disk that you may need to read often and try to minimize writes on your logic thread.

0

Share this post


Link to post
Share on other sites

Game engine functions ought to be doing something non-trivial, therefore any of the overhead that *could* have been removed by such optimizations are such a tiny part of the cost of the function that it doesn't really matter.

 

For those writing an engine, this boundary crossing is something they should have to think about (e.g. they shouldn't provide a vector library that traverses into DLL code every time you add two vectors, but it would be appropriate for it to be provided as source or in a static  library portion of the engine's SDK) but you just need to worry about optimizing your own code. In most cases, this means doing things in algorithmically-sound ways, and getting the most out of the engine by using it in the manner prescribed by its developers. If they've done a reasonable job, your performance should be good unless you do something in a really strange way they didn't anticipate. In short, worry about optimizing *your use of the engine* rather than optimizing the engine itself.

0

Share this post


Link to post
Share on other sites

This is a clear tradeoff.  In exchange for a hypothetical (small) performance loss you get to use a bunch of pre-optimized, debugged, tested code that is known-good and has been used in the wild.  So -- evaluate concerns over a more-than-likely unnecessary micro-optimization versus gains from being able to use that bunch of good code, and decide which you prefer.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0