Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science...

24
Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany

Transcript of Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science...

Page 1: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Accelerating External Search with Bitstate

HashingStefan Edelkamp

Shahid Jabbar

Computer Science DepartmentUniversity of Dortmund, Dortmund,

Germany

Page 2: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

2

Model Checking Given

A model of a system. A specification property

Model Checking Problem: Does the system satisfy the property ?

Method: An exhaustive exploration of the state space to search for a state that does not satisfy the property.

Problem: How to cope with large state spaces that do not fit into the main memory?

Page 3: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

3

Two Very Effective Methods1. External Search:

+ Uses Harddisk to store the state space.+ Implemented on top of SPIN model checker.+ Promising: Largest exploration so far took ~20 GB –

much larger than even the address limits of most computers.

+ Pause and Resume support – Can add more harddisks.- Slow duplicate detection phase

2. Bitstate Hashing (Partial Search):+ Uses only a single bit per state for closed list => faster

duplicates removal.+ What if the size of the open list becomes greater than

the internal memory ?- Solution reconstruction is not possible.

Page 4: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

4

Best of the Both Worlds External Search combined with Bitstate

Hashing+ Faster duplicates removal.+ Open and Closed lists can be saved on the harddisk.+ (Partial) Solution reconstruction.

Page 5: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Outline1. Directed Model Checking2. External Search3. Partial Search4. External Partial Directed Search5. Experimental Results6. Conclusions

Page 6: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

6

Directed Model Checking (Edelkamp, Leue, Lluch-Lafuente, 2004)

A guided search in the state space. Usually by some heuristic estimate. Only promising states are explored. Under-certain conditions proved to be complete. Shorter error trails

Better for human comprehension

Problem: The inevitable demands of the model .. Space, space and space.

Page 7: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

7

Possible Solution Use Virtual Memory.

Assume a bigger address space divided into pages.

Saved on the hard disk but are moved back to the main memory whenever they are “called” – Page Faults.

Pages are mapped to physical locations within the main memory and the desired content is returned from the main memory location.

Page 8: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

8

Problem with the Virtual Memory

0x000…000

0xFFF…FFF

Virtual Address Space

Memory Page

Page 9: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

9

External Memory Model (Aggarwal and Vitter)

Input of size N and N >> M

M

B

Disk

If the input size is very large, running time depends on the I/Os rather than on the number of instructions.

Scan(N) = O(N / B)

Sort(N) = O(N/B log M/B N/B)

Page 10: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

10

External Memory Graph Algorithms External breadth first search [Munagala and

Ranade, 2001]: Generated states flushed to the disk for every BFS level.

No hash table.

Duplicates are removed by sorting the nodes according to the indices and doing an scan and compaction phase.

Before expanding a layer t, the nodes in the layer t-1 and t-2 are subtracted from t.

O(|V| + sort(|V| + |E|)) I/Os. where sort(N) = O(N / B logM/B N / B) I/Os

[Korf, 2003] presented the breadth first search version for implicit graphs.

Page 11: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

11

External BFS

A

t t+1

t+2

BCD

XYZAX

XYZA

XYZ

Duplicates’ Removal

Page 12: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

12

A* Algorithm a.k.a Goal-directed Dijkstra A heuristic estimate is used to guide the search.

E.g. Straight line distance from the current node to the goal in case of a graph with a geometric layout.

Reweighing: w’(u,v) = w(u,v) – h(u) + h(v)

Problems: A* needs to store all the states during exploration. A* generates large amount of duplicates that can be

removed using an internal hash table – only if it can fit in the main memory.

A* do not exhibit any locality of expansion. For large state spaces, standard virtual memory management can result in excessive page faults.

Page 13: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

13

Take a closer look Implicit, unweighted,

undirected graphs

Consistentheuristic estimates.

=> ∆h ={-1,0,1}

g

0

1

2

3

4

5

0 1 2 3 4 5 6

h

It’s a Bucket !

!

Page 14: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

14

Bucket A Bucket is a set of states, residing on the disk, having the

same (g, h) value, Where, g = number of transitions needed to transform the

initial state to the states of the bucket, and h = Estimated distance of the bucket’s state to the goal

No state is inserted again in a bucket that is expanded. If Active (being read or written), represented internally by a

small buffer.

File on diskBuffer in internal memory

Insert state Flush when full

Page 15: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

15

External A* [Edelkamp, Jabbar, and

Schroedl, 2004]

Buckets represent temporal locality – cache efficient order of expansion.

If we store the states in the same bucket together we can exploit the spatial locality.

Munagala and Ranade’s BFS and Korf’s delayed duplicate detection for implicit graphs.

External A*

Page 16: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

16

Complexity Analysis Internal A* => Each edge is

looked at most once. Duplicates Removal:

Sorting the green bucket having one state for every edge from the 3 black buckets.

Scanning and compaction. O(sort(|E|))

Subtraction: Removing states of orange

buckets (duplicates free) from the green one.

O(scan(|V|) + scan(|E|))

Page 17: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

17

I/O Performance of External A*

Theorem: The complexity of External A* in an implicit unweighted and undirected graph with a consistent estimate is bounded by O(sort(|E|) + scan(|V|)) I/Os.

Page 18: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

18

Bitstate Hashing Single bit per state to represent Closed list. Guarantees duplicates removal. But: can remove non-duplicates too – false-

positive. Average probability of a false-positive error

during the search:

m

n

m

i

nP

n

i 2

1 1

0

Since the ith element collides with one of the i-1 already inserted elements with a probability of at most (i-1) / m

n: size of the state space; m: size of the hash table

Page 19: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

19

External Partial Directed SearchProcedure External A*Bucket(0, h(I)) {I}fmin h(I)while (fmin ≠ ∞)

g min{i | Bucket(i, fmin − i) ≠ } while (g ≤ fmin)

h fmin − gforall v є succ(Bucket(g, h))

if (not H[v])H[v] true A(fmin),A(fmin + 1),A(fmin + 2) v

Bucket(g + 1, h + 1) A(fmin + 2) U Bucket(g + 1, h+1)Bucket(g + 1, h) A(fmin + 1) U Bucket(g + 1, h)Bucket(g + 1, h − 1) A(fmin) U Bucket(g + 1, h − 1) g g + 1

fmin min{i + j > fmin | Bucket(i, j) ≠ } U {∞}

H[0 … m – 1]: Bitstate Hashtable for i = 0 to m – 1

H[i] false

Page 20: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

20

Experimental Results -1 Deadlock Detection in Optical Telegraph

# Sta-tions

Sol. Depth

#stored sates

#stored states with bitstate

Time(mm:ss)

Time with bitstate

7 45 333,877 243,318 00:14.47 00:07.39

8 50 420,531 332,963 00:22.25 00:11.20

9 57 9,186,611 6,350,087 17:26.88 04:10.33

Page 21: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

21

Experimental Results -2 CORBA GIOP – 1 Server, N Clients

# Clients

Sol. Depth

#stored sates

#stored states with bitstate

Time(mm:ss)

Time with bitstate

2 58 52,410 48,000 00:11.36 00:03.49

3 70 893,392 809,098 03:03.79 00:43.26

4 75 7,929,710 6,998,693 22:49.23 08:43.01

Page 22: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

22

Experimental Results -3 CORBA GIOP – 2 Servers, N Clients

# Clients

Sol. Depth

#stored sates #stored states with bitstate

Time(mm:ss)

Time with bitstate

3 76 3,431,619 3,127,718 05:43.16 02:42.5

4 81 30,504,630 27,133,946 293:00.00 33:06.28

20 GB space requirement

Page 23: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

23

Experimental Results – 4Negative case Deadlock Detection in Dining Philosophers

# Philoso-phers

Solution Depth

#stored sates

#stored states with bitstate

Time(mm:ss)

Time with bitstate

100 402 999,810 975,459 01:05 01:39

150 603 3,330,456 3,319,312 05:44 06:18

Time to compute the hash value is dominant than external sorting!

Page 24: Accelerating External Search with Bitstate Hashing Stefan Edelkamp Shahid Jabbar Computer Science Department University of Dortmund, Dortmund, Germany.

Shahid Jabbar (Dortmund) Accelerating External Search with Bitstate Hashing

24

Summary State space explosion problem can be circumvented

by Directed External Model Checking or Bitstate Hashing.

Both approaches have some flaws.

A fusion of both approaches cover individual flaws.

Implemented on top of IO-HSF-SPIN – SPIN model checker with external heuristic search.

Gain in speed up till 9 times.

-- THE END --