chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] a cas of chicken overoptimizing


From: Jörg F . Wittenberger
Subject: [Chicken-hackers] a cas of chicken overoptimizing
Date: 13 Feb 2012 18:27:03 +0100

Hi all,

I ran into some data loss, which turned out to be caused
by something which looks to me as if chicken had overoptimised
the following.

(Unfortunately I have an excuse, why I have little time to
test fixes: I'm busy preparing a demo - obviously implemented
in chicken - to be at CeBit!  BTW: Anybody going to be around there?)

Original sequence striped down:

(define (write-blob-to-sql sql identifier last blob c-c)
 (define ins '())
 (define del '())
 (if (vector? blob)
     (begin
        (set! ins (vector-ref blob 1))
        (set! del (vector-ref blob 2))
        (set! blob (vector-ref blob 0))))
 (if (or (pair? ins) (pair? del))
     (<handle-ins-and-del>))
 (<do-some-more>))

"<handle-ins-and-del>" used to be reliably executed for at least a year.

Suddenly I noticed data loss - furtunately the askemos runs from
currently two implementations (rscheme and chicken) and the rscheme
based hosts where uneffected.  Hence the real damage is contained,
because the faulty chicken's could retrieve the data from rscheme.
(Moral: don't rely on bleeding edge, have a backup. ;-)

By tracing the value of "ins" I found that in the case when a vector was
originally passed as "blob" and "ins" was assigned a list, the expression
"(pair? ins)" did return #f even though "ins" clearly was a list a line
above.  Trying to trace the value of "ins" within this predicate
(by passing it to some imported function, which in fact returns the value
unchanged but this is not known to chickens type system) fails, instead
the code returns to the old, correct behavior.

See below for more details.

This is observed with chicken as (and since) updated from git trunk at
Feb 9 noon.  Version 4.7.5.

Best regards

/Jörg

Appending:

To illustrate the details:

;; This is the tracing facility, imported without type info.
(define (debug label value)
(write-to-log-file "Debug ~a ~s\n" label value)
value)

;; This:
(define (write-blob-to-sql sql identifier last blob c-c)
 (define ins '())
 (define del '())
 (if (vector? blob)
     (begin
        (set! ins (vector-ref blob 1))
        (set! del (vector-ref blob 2))
        (set! blob (vector-ref blob 0))))
 (if (or (debug 'PAIR? (pair? ins)) (pair? del))
     (<handle-ins-and-del>))
 (<do-some-more>))

Would log "Debug PAIR? #f" and skip over "<handle-ins-and-del>" while this

(define (write-blob-to-sql sql identifier last blob c-c)
 (define ins '())
 (define del '())
 (if (vector? blob)
     (begin
        (set! ins (vector-ref blob 1))
        (set! del (vector-ref blob 2))
        (set! blob (vector-ref blob 0))))
 (if (or (debug 'PAIR? (pair? (debug 'INS ins))) (pair? del))
     (<handle-ins-and-del>))
 (<do-some-more>))

did log "Debug INS (<<blob>>)" followed by "Debug PAIR? #t" (as
expected) and proceed with "<handle-ins-and-del>".


--------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]