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