Another production use of the infamous circularity detector..

Bryan asks:

    "Is this the only use of this infamous technique in shipping production code?"

Nope.

It took me less than a minute to find a place where the same technique was used in GNU Emacs, in src/print.c:print_object(), in the C implementation of the LISP s-expression printing code.   In LISP systems, the s-expression printer gets used from debuggers and the like; as with dtrace, it's generally bad form to get stuck chasing your tail printing out a broken data structure, so this hack is used a fair bit..

The emacs implementation is slightly different; instead of moving the scout out ahead, it instead has a "halftail" pointer lagging behind, moving at half the speed of the main pointer.  Actually, in the dtrace code in question, the half-tail approach might be slightly more efficient in the normal case where the data
structures aren't circular and the thing you're looking for is usually in the list.

Comments:

Post a Comment:
Comments are closed for this entry.
About

sommerfeld

Search

Top Tags
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today