Re: [Chicken-users] New egg: hopefully
Am 19.12.2015 um 23:31 schrieb Sudarshan S Chawathe: > Thanks for the update. I see the same behavior with tests/run.scm as > before: Compilation with csc is fine, but executing the resulting file > 'run' gives exactly the same error as before: > > Error: assertion failed: (= (obox-v b1) 455) > > (Detailed error message is same as in my earlier message.) Hm, that's strange. I blindly assumed this to somehow follow from the import gone wrong. Now I did no do much yesterday but re-run this over and over again to tune the implementation. Neither on 4.9.1 or master. Could you please _replace_ the let form in run.scm starting around line 217 with the one below and try. Should give me more details. The expected output: D #: also in other thread former ref is still unchanged... D even after commit. (Note: tests caching of references to fields.): 9 T2 x cc 2 6 T1 x cc 2 7 T2 y cc 2 7 T2 done cc 2 65 T1 y cc -2 6 T1 done cc -2 42 T1 x cc -3 7 T1 y cc -3 65 T1 done cc -3 455 D M1: not-owned D M2: not-abandoned Locking 2 op in 1530.0 ms (13.0718954248366 op/ms) Optimistic 2 op in 1324.0 ms (15.1057401812689 op/ms) Thanks for your help. /Jörg Here the more verbose test expression: (let ((mux1 (make-mutex 'T1)) (mux2 (make-mutex 'T2)) (call-count 0)) (define (step! msg mux1 mux2 val) (mutex-unlock! mux1) (if (and mux2 (> call-count 0) (< call-count 100)) (mutex-lock! mux2 #f #f)) (if msg (format (current-error-port) "~a cc ~a ~a\n" msg call-count val)) val) (mutex-lock! mux1 #f #f) (mutex-lock! mux2 #f #f) (thread-start! (lambda () (call-with-transaction (lambda (tnx) (if (>= call-count 0) (set! call-count (add1 call-count)) (set! call-count (sub1 call-count))) (if (< call-count 100) (let ((a (obox-v-ref b2 tnx)) (b (obox-v-ref b1 tnx))) ;; Normally one should never do this. We enforce thread ;; switches during transaction. (alter! a (let* ((x (step! "T2 x" mux1 mux2 (cell-ref a))) (y (step! "T2 y" mux1 mux2 (cell-ref b (+ 23 (* x y (step! "T2 done" mux1 #f (cell-ref a))) (step! "T2 call count exceeded" mux1 #f call-count (set! call-count (- call-count (call-with-transaction (lambda (tnx) (if (>= call-count 0) (set! call-count (add1 call-count)) (set! call-count (sub1 call-count))) (let ((a (obox-v-ref b1 tnx)) (b (obox-v-ref b2 tnx))) (alter! a (let* ((x (step! "T1 x" mux2 mux1 (cell-ref a))) (y (step! "T1 y" mux2 mux1 (cell-ref b (* x y))) (step! "T1 done" mux2 #f (cell-ref a) (assert (= call-count -3)) ;; -- not defined to be -3, but normally (dbg 'M1 (mutex-state mux1)) (dbg 'M2 (mutex-state mux2)) (assert (= (obox-v b1) 455)) (assert (= (obox-v b2) 65))) ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] New egg: hopefully
Thanks for following up. I hope the cause isn't something silly in my setup. I ran tested with a run.scm modified as you indicated, except that I'm guessing you meant line 127, not 217. (I couldn't find any obvious match on line 217, so I replaced the one starting on line 127.) The results are attached. It fails the assertion: (assert (= call-count -3)) Regards, -chaw > From: joerg.wittenber...@softeyes.net > Date: Sun, 20 Dec 2015 15:07:17 +0100 > Subject: Re: [Chicken-users] New egg: hopefully > > Am 19.12.2015 um 23:31 schrieb Sudarshan S Chawathe: > > Thanks for the update. I see the same behavior with tests/run.scm as > > before: Compilation with csc is fine, but executing the resulting file > > 'run' gives exactly the same error as before: > > = > > > Error: assertion failed: (=3D (obox-v b1) 455) > > = > > > (Detailed error message is same as in my earlier message.) > > Hm, that's strange. I blindly assumed this to somehow follow from the > import gone wrong. > > Now I did no do much yesterday but re-run this over and over again to > tune the implementation. Neither on 4.9.1 or master. > > Could you please _replace_ the let form in run.scm starting around line > 217 with the one below and try. Should give me more details. > > The expected output: > > D #: also in other thread former ref is still > unchanged... > D even after commit. (Note: tests caching of references to fields.): 9 > T2 x cc 2 6 > T1 x cc 2 7 > T2 y cc 2 7 > T2 done cc 2 65 > T1 y cc -2 6 > T1 done cc -2 42 > T1 x cc -3 7 > T1 y cc -3 65 > T1 done cc -3 455 > D M1: not-owned > D M2: not-abandoned > Locking 2 op in 1530.0 ms (13.0718954248366 op/ms) > Optimistic 2 op in 1324.0 ms (15.1057401812689 op/ms) > > Thanks for your help. > > /J=F6rg > > Here the more verbose test expression: > > (let ((mux1 (make-mutex 'T1)) (mux2 (make-mutex 'T2)) > (call-count 0)) > (define (step! msg mux1 mux2 val) > (mutex-unlock! mux1) > (if (and mux2 (> call-count 0) (< call-count 100)) (mutex-lock! mux2 > #f #f)) > (if msg (format (current-error-port) "~a cc ~a ~a\n" msg call-count > val)) > val) > (mutex-lock! mux1 #f #f) > (mutex-lock! mux2 #f #f) > (thread-start! >(lambda () > (call-with-transaction > (lambda (tnx) > (if (>=3D call-count 0) (set! call-count (add1 call-count)) > (set! call-count (sub1 call-count))) > (if (< call-count 100) > (let ((a (obox-v-ref b2 tnx)) > (b (obox-v-ref b1 tnx))) > ;; Normally one should never do this. We enforce thread > ;; switches during transaction. > (alter! > a > (let* ((x (step! "T2 x" mux1 mux2 (cell-ref a))) >(y (step! "T2 y" mux1 mux2 (cell-ref b >(+ 23 (* x y > (step! "T2 done" mux1 #f (cell-ref a))) > (step! "T2 call count exceeded" mux1 #f call-count > (set! call-count (- call-count > (call-with-transaction >(lambda (tnx) > (if (>=3D call-count 0) (set! call-count (add1 call-count)) > (set! call-count (sub1 call-count))) > (let ((a (obox-v-ref b1 tnx)) > (b (obox-v-ref b2 tnx))) >(alter! > a > (let* ((x (step! "T1 x" mux2 mux1 (cell-ref a))) > (y (step! "T1 y" mux2 mux1 (cell-ref b > (* x y))) >(step! "T1 done" mux2 #f (cell-ref a) > (assert (=3D call-count -3)) ;; -- not defined to be -3, but normally > (dbg 'M1 (mutex-state mux1)) > (dbg 'M2 (mutex-state mux2)) > (assert (=3D (obox-v b1) 455)) > (assert (=3D (obox-v b2) 65))) $ csc run2.scm $ ./run2 D CALL: # D Initial: set D Value in other thread is unchanged...: 9 D #: also in other thread former ref is still unchanged... D even after commit. (Note: tests caching of references to fields.): 9 D Value in other thread is unchanged...: 9 D Second round expecting changed value: 252 D #: also in other thread former ref is still unchanged... D even after commit. (Note: tests caching of references to fields.): 9 T2 x cc 2 6 T1 x cc 2 7 T1 y cc 2 6 T1 done cc 2 42 Error: (run2.scm:169) assertion failed: (= call-count -3) Call history: run2.scm:166: step! run2.scm:130: mutex-unlock! run2.scm:131: mutex-lock! run2.scm:133: format run2.scm:163: hopefully-intern#alter! run2.scm:168: hopefully-intern#cell-ref run2.scm:168: step! run2.scm:130: mutex-unlock! run2.scm:133: format hopefully.scm:264: transaction-commit! hopefully.scm:222: loop hopefully.scm:228: loop hopefully.scm:200: hopefully-intern-atomics#transaction-close! hopefully-intern-atomics.scm:185: transaction-reset! hopefully-intern-atomics.scm:34: ##sys#block-set! run2.scm:169: ##sys#error <-- $
Re: [Chicken-users] New egg: hopefully
Am 20.12.2015 um 15:50 schrieb Sudarshan S Chawathe: > > Thanks for following up. I hope the cause isn't something silly in my > setup. > > I ran tested with a run.scm modified as you indicated, except that I'm > guessing you meant line 127, not 217. (I couldn't find any obvious Yes, 127 is correct. ;-) > match on line 217, so I replaced the one starting on line 127.) The > results are attached. It fails the assertion: > > (assert (= call-count -3)) This, and your'e getting a different execution sequence and all. Now this assert used to be commented out, since it's not by definition, but expected. I currently do not understand why T2 is not winning the race. Could you ignore that please for a moment (comment out). I'm interested in the mutex's state. Also please insert a thread-sleep! right after those debug prints, so we see what T2 is doing here. Like so (first and last line unchanged): (step! "T1 done" mux2 #f (cell-ref a) ;;(assert (= call-count -3)) ;; -- not defined to be -3, but normally (dbg 'M1 (mutex-state mux1)) (dbg 'M2 (mutex-state mux2)) (thread-sleep! 1) (assert (= (obox-v b1) 455)) > > Regards, > > -chaw > >> From: joerg.wittenber...@softeyes.net >> Date: Sun, 20 Dec 2015 15:07:17 +0100 >> Subject: Re: [Chicken-users] New egg: hopefully >> >> Am 19.12.2015 um 23:31 schrieb Sudarshan S Chawathe: >>> Thanks for the update. I see the same behavior with tests/run.scm as >>> before: Compilation with csc is fine, but executing the resulting file >>> 'run' gives exactly the same error as before: >>> = >> >>> Error: assertion failed: (=3D (obox-v b1) 455) >>> = >> >>> (Detailed error message is same as in my earlier message.) >> >> Hm, that's strange. I blindly assumed this to somehow follow from the >> import gone wrong. >> >> Now I did no do much yesterday but re-run this over and over again to >> tune the implementation. Neither on 4.9.1 or master. >> >> Could you please _replace_ the let form in run.scm starting around line >> 217 with the one below and try. Should give me more details. >> >> The expected output: >> >> D #: also in other thread former ref is still >> unchanged... >> D even after commit. (Note: tests caching of references to fields.): 9 >> T2 x cc 2 6 >> T1 x cc 2 7 >> T2 y cc 2 7 >> T2 done cc 2 65 >> T1 y cc -2 6 >> T1 done cc -2 42 >> T1 x cc -3 7 >> T1 y cc -3 65 >> T1 done cc -3 455 >> D M1: not-owned >> D M2: not-abandoned >> Locking 2 op in 1530.0 ms (13.0718954248366 op/ms) >> Optimistic 2 op in 1324.0 ms (15.1057401812689 op/ms) >> >> Thanks for your help. >> >> /J=F6rg >> >> Here the more verbose test expression: >> >> (let ((mux1 (make-mutex 'T1)) (mux2 (make-mutex 'T2)) >> (call-count 0)) >> (define (step! msg mux1 mux2 val) >> (mutex-unlock! mux1) >> (if (and mux2 (> call-count 0) (< call-count 100)) (mutex-lock! mux2 >> #f #f)) >> (if msg (format (current-error-port) "~a cc ~a ~a\n" msg call-count >> val)) >> val) >> (mutex-lock! mux1 #f #f) >> (mutex-lock! mux2 #f #f) >> (thread-start! >>(lambda () >> (call-with-transaction >> (lambda (tnx) >> (if (>=3D call-count 0) (set! call-count (add1 call-count)) >> (set! call-count (sub1 call-count))) >> (if (< call-count 100) >> (let ((a (obox-v-ref b2 tnx)) >>(b (obox-v-ref b1 tnx))) >>;; Normally one should never do this. We enforce thread >>;; switches during transaction. >>(alter! >> a >> (let* ((x (step! "T2 x" mux1 mux2 (cell-ref a))) >> (y (step! "T2 y" mux1 mux2 (cell-ref b >> (+ 23 (* x y >>(step! "T2 done" mux1 #f (cell-ref a))) >> (step! "T2 call count exceeded" mux1 #f call-count >> (set! call-count (- call-count >> (call-with-transaction >>(lambda (tnx) >> (if (>=3D call-count 0) (set! call-count (add1 call-count)) >>(set! call-count (sub1 call-count))) >> (let ((a (obox-v-ref b1 tnx)) >> (b (obox-v-ref b2 tnx))) >>(alter! >> a >> (let* ((x (step! "T1 x" mux2 mux1 (cell-ref a))) >>(y (step! "T1 y" mux2 mux1 (cell-ref b >>(* x y))) >>(step! "T1 done" mux2 #f (cell-ref a) >> (assert (=3D call-count -3)) ;; -- not defined to be -3, but normally >> (dbg 'M1 (mutex-state mux1)) >> (dbg 'M2 (mutex-state mux2)) >> (assert (=3D (obox-v b1) 455)) >> (assert (=3D (obox-v b2) 65))) > > > > ___ > Chicken-users mailing list > Chicken-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/chicken-users > ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users