Almansur Metrics - UW Departments Web Server

Almansur:
Extendable
Implementation
and Parallelization Using
MASS
Stuart Drummond
Introduction
Almansur Overview
• Massively multiplayer online turn-based
strategy game
• Built using Ruby on Rails by PDMFC
• Originally released in 2007
• Created using agent-based modeling
Introduction
Slide 1
MASS
• Created and maintained by Dr.
Munehiro Fukuda and Distributed
System Lab at UW Bothell
• What is it?
• Places & Agents
• Using multiple computing nodes via
grid computing to parallelize
• Versions
• Java and C++
• Which one is being used for the
project?
Introduction
Slide 2
Game parallelization &
Benchmarking
• Specific to games in web…
• Most literature had to do parallelizing
and scaling game server
• AlBahnassi, Mudur, & Goswami, 2012
• Use of task parallelism
• External validity in benchmarking
Introduction
Slide 3
Agent-Based Systems
• What are agents?
• Macal & North (2008)
• What are the features of
agents?
• Autonomy
• Social relationships
• Reactivity
• Proactiveness
• What kind of systems could
benefit from agent-based
systems?
Introduction
Not this kind of
agents
Slide 4
Project Overview &
Implementation
The Problem and
Requirements
• Overall Speed
Ding, Gernart, Li & Hertz (2014)
• Turn Processing
• Functional Requirement
• Performance
• Non-functional Requirements
• Extendibility
Project Overview
Slide 1
Benchmarking Results (Ribeiro,
Santos, & Prada 2007)
Number of agents vs processing time
350
300
Processing time (sec)
250
200
150
100
50
0
0
1000
2000
3000
4000
5000
6000
Agents
Project Overview
Slide 2
Benchmarking Results (Ribeiro,
Santos, & Prada 2007)
Number of agents vs processing time
350
300
Processing time (sec)
250
200
150
100
50
0
0
-50
Project Overview
1000
2000
3000
4000
5000
6000
Agents
Slide 3
Worst case scenario…
Number of agents vs processing time
350
300
Processing time (sec)
250
200
150
100
50
0
0
1000
2000
3000
4000
5000
6000
Agents
Project Overview
Slide 4
Project Hypothesis
• H0: There is no difference in performance between the
original version of Almansur and the MASS-optimized
Almansur.
• H1: The amount of time that it takes to conduct turn
processing will be significantly faster in the MASSoptimized Almansur.
• Operational Definition
• Speed: Less than 5% change in difference is considered
within margin of error.
Project Overview
Slide 5
Architecture
Implementations
Slide 6
Components of
Almansur
Implementations
Slide 7
MASS-optimized Almansur
Implementations
Slide 8
World.
process_turn()
Implementations
Slide 9
Event Manager
• Class responsible for relaying events from
turn processing to agents.
• Reads from a JSON file and parsed by
GSON.
• Additional processing to determine if the
target is a place or an agent.
Implementations
Slide 10
Event Manager Continued…
Implementations
Slide 11
JSON File
Implementations
Slide 12
Source code documentations
Source Code Element Type
What does it mean?
DB CONSTS
These are constant values that will provide the index to some specific N/A
variable in the Object array that represents a row in the database.
REFERENCE CONSTS
These are constants to do comparison in reference methods.
N/A
CALCULATION CONSTS
These are constants that are used to calculate some value for turn
processing.
N/A
CONSTRUCTORS
Method to construct object.
No
ACCESSORS
Methods to act some database value from this object.
No
MUTATORS
Methods to change some database value from this object.
No
REFERENCE METHODS
Static methods used by reference to compare/retrieve values with
the reference.
Yes
LEGACY METHODS
Other methods used by the original version to calculate some values
required for turn processing. The name of the method is left the
same as the one in the Ruby version for easy identification.
Yes
Implementations
Docume
nted?
Slide 13
Methods
Performance Metrics
• Ruby benchmarking modules
• Using System.currentTimeMillis() at two
points.
• Graph + performance difference
percentage table
• Process 1 turn
• PC used for testing:
Methods
•
•
•
•
CPU: i7 2600k @ 4.7 GHz
Memory: 8 GB RAM
Storage: Samsung 830 Pro SSD
GPU: 2x Nvidia GTX 780 TI
Slide 1
Scenario Selection
•Using the same set of scenarios
used by the graduate student at
PDMFC
•Importing provided SQL dumps
•Scenarios:
•
•
•
•
Methods
Small scenario with 2 Lands
Large scenario with 200 Lands
Very large scenario with 500 Lands
Huge scenario with 1000 Lands
Slide 2
Results
Scenario 1 Table (Milliseconds)
1 Node
Ruby
Performance
Change
Number of Lands: 2
Number of Agents: 511
Results
1 Thread
226
878
74.260%
2 Threads
188
878
78.588%
4 Threads
187
878
78.702%
Slide 1
Scenario 2 Table (Milliseconds)
1 Node
Ruby
Max diff
Number of Lands: 200
Number of Agents: 28005
Results
1 Thread
661
23,893
97.233%
2 Threads
624
23,893
97.388%
4 Threads
610
23,893
97.447%
Slide 2
Scenario 3 Table (Milliseconds)
1 Node
Ruby
Max diff
Number of Lands: 500
Number of Agents: 65420
Results
1 Thread
1123
56,245
98.000%
2 Threads
1024
56,245
98.180%
4 Threads
1018
56,245
98.190%
Slide 3
Scenario 4 Table (Milliseconds)
1 Node
Ruby
Max diff
Number of Lands: 1000
Number of Agents: 126424
Results
1 Thread
1947
109,543
98.222%
2 Threads
1646
109,543
98.497%
4 Threads
1586
109,543
98.552%
Slide 4
Performance Scatterplot
PROCESS TIME VS NUMBER OF AGENTS
Mass Thread 1
Mass Thread 2
Mass Thread 4
Ruby
PROCESS TIME (MILLISECONDS)
120000
100000
80000
60000
40000
20000
0
0
20000
40000
60000
80000
100000
120000
140000
NUMBER OF AGENTS
Results
Slide 5
Conclusions
Hypothesis Revisited
•The implementation using MASS allowed for a processing time
that was better than the original version
• Was able to reject the null hypothesis
•Performance bottleneck?
• Any operation that involve having to refer back to the Lands /
Political Entities create sections of code where parallelizable
become impossible
•Innate issue with the original design
• Future implementation may start individualizing from the
original software
Conclusions
Slide 1
Limitations
•No multi-process results
•Low sample size
•Repetitive importing code
•Some processes are missing
Conclusions
Slide 2
Future extensions
•Web extension
• Proper scenario importing and exporting
•Additional processing
•Further testing
Conclusions
Slide 3
Lessons Learned
•The requirements of a project changes…often
•Having a library that can evolve is helpful for a
project
•Assuming anything about the source code is risky!
•Communication is key
•Porting from a dynamic-typed language to a statictyped language is difficult.
Conclusions
Slide 4
References
• Active record pattern. (2005, October 11). Retrieved September 1, 2014, from http://en.wikipedia.org/wiki/Active_record_pattern
• Adobbati, R., Marshall, A. N., Scholer, A., Tejada, S., Kaminka, G. A., Schaffer, S., & Sollitto, C. (2001, January). Gamebots: A 3d virtual world test-bed for multi-agent research.
In Proceedings of the second international workshop on Infrastructure for Agents, MAS, and Scalable MAS (Vol. 5). Montreal, Canada.
• AlBahnassi, W., Mudur, S. P., & Goswami, D. (2012, June). A Design Pattern for Parallel Programming of Games. In High Performance Computing and Communication & 2012 IEEE 9th
International Conference on Embedded Software and Systems (HPCC-ICESS), 2012 IEEE 14th International Conference on (pp. 1007-1014). IEEE.
• Almansur. (2005). Free online medieval strategy turn based game. Retrieved May 1, 2014, from http://www.almansur.net/
• Barata, A. M., Santos, P. A., & Prada, R. (2011, September). AI for Massive Multiplayer Online Strategy Games. In AIIDE.
• Chiu, A., Nasiri, E., & Rashid, R. (2012). Parallelization of Sudoku.
• Ding, C., Gernhart, B., Li, P., & Hertz, M. (2014). Safe parallel programming in an interpreted language (Vol. 991). Technical Report.
• Dong, J., Chen, S., & Jeng, J. J. (2005, April). Event-based blackboard architecture for multi-agent systems. In Information Technology: Coding and Computing, 2005. ITCC 2005.
International Conference on (Vol. 2, pp. 379-384). IEEE.
• Fukuda, M. (2014, January 30). MASS: A Parallelizing Library for Multi-Agent Spatial Simulation. MASS: A Parallelizing Library for Multi-Agent Spatial Simulation. Retrieved May 1, 2014,
from http://depts.washington.edu/dslab/MASS/index.html
• Jruby. (n.d.). Retrieved August 20, 2014.
• Macal, C. M., & North, M. J. (2008, December). Agent-based modeling and simulation: ABMS examples. In Proceedings of the 40th Conference on Winter Simulation (pp. 101-112).
Winter Simulation Conference.
• Ribeiro, L. M. L., Santos, P., & Prada, R. (2007). Agents for Massive On-line Strategy Turn Based Games.
• Ruby. (n.d.). Programming Language. Retrieved May 16, 2014, from https://www.ruby-lang.org/en
• Ruby on Rails. (n.d.). Retrieved August 20, 2014, from http://rubyonrails.org/
• StarCraft II. (2010, January 1). Retrieved August 20, 2014, from http://us.battle.net/sc2/en/?-