almansur: extendable implementation and parallelization using mass stuart drummond

35
Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Upload: cori-bridges

Post on 20-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Almansur: Extendable Implementation and Parallelization Using MASS

Stuart Drummond

Page 2: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Introduction

Page 3: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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

Slide 1Introduction

Page 4: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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? Slide 2Introduction

Page 5: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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

Slide 3Introduction

Page 6: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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?

Not this kind of agents

Slide 4Introduction

Page 7: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Project Overview & Implementation

Page 8: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

The Problem and Requirements

• Overall Speed Ding, Gernart, Li & Hertz (2014)

• Turn Processing

• Functional Requirement• Performance

• Non-functional Requirements• Extendibility

Slide 1Project Overview

Page 9: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Benchmarking Results (Ribeiro, Santos, & Prada 2007)

0 1000 2000 3000 4000 5000 60000

50

100

150

200

250

300

350

Number of agents vs processing time

Agents

Pro

cessin

g t

ime (

sec)

Slide 2Project Overview

Page 10: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Benchmarking Results (Ribeiro, Santos, & Prada 2007)

0 1000 2000 3000 4000 5000 60000

50

100

150

200

250

300

350

Number of agents vs processing time

Agents

Pro

cessin

g t

ime (

sec)

Slide 3Project Overview

Page 11: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Worst case scenario…

0 1000 2000 3000 4000 5000 60000

50

100

150

200

250

300

350

Number of agents vs processing time

Agents

Pro

cessin

g t

ime (

sec)

Slide 4Project Overview

Page 12: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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 MASS-optimized Almansur.

• Operational Definition• Speed: Less than 5% change in difference is

considered within margin of error.

Slide 5Project Overview

Page 13: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Architecture

Slide 6Implementations

Page 14: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Components of Almansur

Slide 7Implementations

Page 15: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

MASS-optimized Almansur

Slide 8Implementations

Page 16: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Implementations

Slide 9

World.process_turn()

Page 17: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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.

Slide 10Implementations

Page 18: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Event Manager Continued…

Slide 11Implementations

Page 19: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

JSON File

Slide 12Implementations

Page 20: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Source code documentationsSource Code Element Type What does it mean? Docu

mented?

DB CONSTS These are constant values that will provide the index to some specific variable in the Object array that represents a row in the database.

N/A

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.

YesSlide 13Implementatio

ns

Page 21: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Methods

Page 22: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Performance Metrics• Ruby benchmarking modules

• Using System.currentTimeMillis() at two points.

• Graph + performance difference percentage table

• Process 1 turn

• PC used for testing:• CPU: i7 2600k @ 4.7 GHz• Memory: 8 GB RAM• Storage: Samsung 830 Pro SSD• GPU: 2x Nvidia GTX 780 TI Slide 1Methods

Page 23: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Scenario Selection

•Using the same set of scenarios used by the graduate student at PDMFC

•Importing provided SQL dumps

•Scenarios:• Small scenario with 2 Lands• Large scenario with 200 Lands• Very large scenario with 500 Lands• Huge scenario with 1000 Lands

Slide 2Methods

Page 24: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Results

Page 25: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Scenario 1 Table (Milliseconds)

Slide 1Results

1 Node Ruby Performance Change

1 Thread 226 878 74.260%

2 Threads 188 878 78.588%

4 Threads 187 878 78.702%

Number of Lands: 2

Number of Agents: 511

Page 26: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Scenario 2 Table (Milliseconds)

Slide 2Results

1 Node Ruby Max diff

1 Thread 661 23,893 97.233%

2 Threads 624 23,893 97.388%

4 Threads 610 23,893 97.447%

Number of Lands: 200

Number of Agents: 28005

Page 27: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Scenario 3 Table (Milliseconds)

Slide 3Results

1 Node Ruby Max diff

1 Thread 1123 56,245 98.000%

2 Threads 1024 56,245 98.180%

4 Threads 1018 56,245 98.190%

Number of Lands: 500

Number of Agents: 65420

Page 28: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Scenario 4 Table (Milliseconds)

Slide 4Results

1 Node Ruby Max diff

1 Thread 1947 109,543 98.222%

2 Threads 1646 109,543 98.497%

4 Threads 1586 109,543 98.552%

Number of Lands: 1000

Number of Agents: 126424

Page 29: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Performance Scatterplot

Slide 5Results

0 20000 40000 60000 80000 100000 120000 1400000

20000

40000

60000

80000

100000

120000

Process Time vs Number of AgentsMass Thread 1 Mass Thread 2 Mass Thread 4 Ruby

Number of Agents

Pro

cess

Tim

e (

Millise

con

ds)

Page 30: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Conclusions

Page 31: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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

Slide 1Conclusions

Page 32: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Limitations

•No multi-process results

•Low sample size

•Repetitive importing code

•Some processes are missing

Slide 2Conclusions

Page 33: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

Future extensions•Web extension

• Proper scenario importing and exporting

•Additional processing

•Further testing

Slide 3Conclusions

Page 34: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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 static-typed language is difficult.

Slide 4Conclusions

Page 35: Almansur: Extendable Implementation and Parallelization Using MASS Stuart Drummond

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/?-