Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Project Earl Grey

2,013 views

Published on

Brief introduction of concepts and architecture of open-source online game server library Earlgrey.

Published in: Technology
  • If you need your papers to be written and if you are not that kind of person who likes to do researches and analyze something - you should definitely contact these guys! They are awesome ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Project Earl Grey

  1. 1. Earl Grey<br />Concepts & Architecture for Dummies<br />
  2. 2. What is it?<br />Online game server framework <br />Open source project with MIT license<br />http://code.google.com/p/earlgrey/<br />Still under development<br />
  3. 3. Keywords<br />Intel x86/x64 (Itanium)<br />Multi processor machine <br />Plenty of main memory<br />Windows Vista/2003 and newer (Official)<br />Windows XP/2000 (Non-official)<br />Standalone (Without third-party libraries)<br />Lock-free algorithm (Threading)<br />IO Completion Port (Network)<br />
  4. 4. Vision<br /> Provides basic functionalities and extensible architecture needed to build high performing, still solid online game servers<br />
  5. 5. Threading – Task analysis<br />Two different kinds of tasks<br />CPU-bound<br />takes a lot of CPU usages<br />takes computer resources just for a short time<br />Examples: HP calculation <br />IO-bound<br />takes relatively less CPU usages<br />takes computer resources for a long time<br />Examples: database operations<br />
  6. 6. Threading – Thread groups<br />CPU-bound  IOCP thread group <br />Client requests<br />IO-bound <br />Not yet implemented<br />Database operations<br />Logging operations (Separation from IO-bound thread group is being considered)<br />Main thread<br />Starts and ends the application<br />
  7. 7. Threading - Performance<br />Race condition<br />One resource / Multiple threads<br />Best solution is not to share it!<br />Cache invalidation<br />One task / Multiple processors<br />Best solution is to attach a thread to a specific processor <br />A task should be fully processed in a thread<br />Can’t depend on OS’ optimization<br />
  8. 8. Threading - Performance<br />CPU-bound thread group<br />No waiting!<br />Waiting means a thread unavailable<br />Posts IO-bound tasks to the IOCP thread group.<br />Message posting mechanism is required.<br />Request should be processed in a short time<br />A processor takes only one thread.<br />
  9. 9. Threading - Performance<br />IO-bound thread group<br />Waiting is inevitable for some kinds of operations.<br />Assign multiple threads to a processor<br />Best receipt should be decided by a hand or a some mechanism which is not yet developed.<br />
  10. 10. Threading - Performance<br />Each thread holds copies of read-only or no-need-to-be-shared resources.<br />Ex) Internal buffers of FromUnicode function.<br />Race condition is resolved by lock-free containers.<br />Traditional locking mechanism is still being used for one-time initialization of singleton instances.<br />Message posting mechanism<br />Each thread/thread group has its own roles.<br />Copying data usually results in better performance than just waiting for shared resources.<br />
  11. 11. Memory – GreedyAllocator<br />Global heap allocator.<br />Greedy?<br />Never return memory space to OS.<br />Structure is relatively simple  High performance. <br />Designed on the assumption that each application has a dedicated machine.<br />Not yet optimized<br />Cache line size<br />Large page size (if a processor supports)<br />
  12. 12. Memory – ThreadLocalAllocator<br />Minimize race conditions and waiting time.<br />Each thread has its own memory pool.<br />If a thread has shortage of memory space, send a request to a global heap allocator.<br />If thread A has plenty of memory space and thread B has shortage, a memory manager send a memory chunk from A to B.<br />Faster about 10 times than Windows’ low-fragmentation heap.<br />
  13. 13. Memory – StackAllocator<br />Allocates memory on the stack (_malloca).<br />Free allocated memory space automatically.<br />Allocation is super-fast.<br />Simple real-time check is implemented.<br />
  14. 14. Memory – Third-parties<br />TBBAllocator<br />Intel Threading Block Library<br />LFHAllocator<br />Low-fragmentation Heap Allocator<br />
  15. 15. Memory – STL support<br />x-containers/x-streams<br />Using a global heap allocator (GreedyAllocator)<br />Fast<br />xwstring, xwstringstream, xvector, and so on<br />auto-containers/auto-streams<br />Using a stack allocator (StackAllocator)<br />Super-fast<br />Life cycle of instances should be carefully considered<br />auto_wstring, auto_wstringstream, and so on<br />
  16. 16. Future tasks<br />Complete feature set of asynchronous networking.<br />Rich set of diagnostics<br />Rolling log file/DebugOutput loggings and so on <br />Integration with third-party libraries like log4cxx<br />Performance tuning (Ex. detecting a heavy request)<br />IO-bound thread group<br />Administration tool <br />Telnet-based tool for Win32 services<br />
  17. 17. Credit<br />Cover photohttp://www.flickr.com/photos/kankan/41403840<br />

×