Fork Join
-
Upload
neueda -
Category
Technology
-
view
967 -
download
4
Transcript of Fork Join
Fork Join Framework
Java framework for supporting a style of parallel
programming in which problems are solved by
(recursively) splitting them into subtasks that are
solved in parallel, waiting for them to complete,
and then composing results.
http://gee.cs.oswego.edu/dl/papers/fj.pdf
Algorithm
Result solve(Problem problem) {
if (problem is small)
directly solve problem
else {
split problem into independent parts
fork new subtasks to solve each part
join all subtasks
compose result from subresults
}
}
Core classes
Differences from
ThreadPoolExecutor
Suited for recursive tasks and “divide and
conquer” algorithms
Work stealing
Work Stealing
Wait for all threads to complete their tasks
Initial state
Work Stealing
Wait for all threads to complete their tasks
Other threads are idle until the first thread finished
Part II
Practical example
Passwords are rarely kept in cleartext
nowadays
The problem: restore passwords from a list
of password hashes with Rainbow attack
Rainbow attack
http://en.wikipedia.org/wiki/Rainbow_attack
Build a Rainbow table using the list of
possible passwords
Lookup passwords in the table
The algorithm
Load top 2000 english words
Add all case permutations
Add numbers 0-9
Results in 6 000 000 combinations
Compute hashes
Lookup hashes in the table
How ForkJoin can help?
CPU intensive tasks
Generate the list of all possible passwords
Compute hashes
Let’s see some code!
Test results
Tested on Amazon EC2 Extra Large
instance running 64 bit AMI Linux
15 Gb RAM, 4 processors
Rainbow table size: 6 041 508
Input: list of 1000 MD5 hashes
Found all 10 passwords
Test results
Sequential 2 threads 4 threads 8 threads
Threads 1 2 4 8
Run 1 10967 7278 5465 5451
Run 2 9176 7195 5687 5646
Run 3 8083 5270 4338 4025
Run 4 9244 6515 5507 5005
Run 5 9279 7265 6497 5650
Avg 9350 6705 5499 5155
Speedup 0% 28% 41% 45%
0%
10%
20%
30%
40%
50%
1 2 4 8
Bonus slide - Offtopic
Never keep passwords in cleartext!
MD5 is a bad choice
Always add “salt” to passwords
The right way: use Bcrypt!
More offtopic
The “pastebin” experiment
http://pastebin.com/1iL2P0G5
Found one password “a1”
Questions
Thank you!