Re: [Chicken-hackers] [PATCH] Declare _WIN32_WINNT for access to timer functions on mingw32

2016-02-20 Thread Peter Bex
On Wed, Feb 17, 2016 at 02:08:08PM +1300, Evan Hanson wrote:
> 32-bit MinGW requires _WIN32_WINNT >= 0x0500 in order to access the
> CreateTimerQueueTimer and DeleteTimerQueueTimer functions, which are
> used by the statistical profiler.

Looks like this is only required on Windows 7 for some obscure reason.
Either that or I'm running an older version MingW under my Vista VM.
Anyway, who cares, this fixes the problem.  Pushed.

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] PATCH Re: slow polling

2016-02-20 Thread Jörg F . Wittenberger
Fixes for last patch.

Sorry, this had to happen sooner or later.

This patch just fixes use of outdates predicates.

Cheers

/Jörg

BTW: Interesting that this did work to some extend.  (#1 reason to begin
with the timeout queue was that the original code still uses fixnum
timeouts for backward compatibility).

Am 20.02.2016 um 18:54 schrieb Jörg F. Wittenberger:
> Am 19.02.2016 um 22:39 schrieb Jörg F. Wittenberger:
>> ...
>>> I opened ticket 1259 for this.
>>>
>>> To make the kind reviewers job easier, I'll post diffs in piecemeal here.
> 
> This patch goes after killing a single - but important - comment line in
> scheduler.scm:
> 
> ;; This should really use a balanced tree:
> 
> Now it does.
> 
> This patch replaces the timeout queue with a balanced tree.
> 
> 
>It does not matter so much, which kind of tree we use.  But a
>linear list is really a bad choice.
> 
>Assume you have a tcp-server alike: 100 client connections and
>you read the next input line.  It's probably (but not sure) already
>in the OS's buffer.  But chicken core will nevertheless establish a
>timeout.  The latter will so far traverse the (linear) timeout
>queue.  Chances are all those other timeouts are prior established
>reads using the same timeout too.  Thus you find the insert point
>right at the end.
> 
> 
> If you have an application which makes heavy use of chicken's core tcp
> unit (I don't use chicken's timeouts at all for this, I do use them, but
> only via thread-sleep!) I'd be interested to hear how much good or bad
> this patch does for you.
> 
> Cheers
> 
> /Jörg

>From 697b8780cb57a9720affc8216d194c211fdef49a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20F=2E=20Wittenberger?=
 
Date: Sat, 20 Feb 2016 19:15:26 +0100
Subject: [PATCH] Fix missuse of predicate

---
 scheduler.scm | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scheduler.scm b/scheduler.scm
index 997668f..7081acf 100644
--- a/scheduler.scm
+++ b/scheduler.scm
@@ -334,8 +334,7 @@ EOF
 (let ((entry (make-timeout-list-entry tm (list t
   (##sys#setslot t 4 entry)
   (set! ##sys#timeout-list-head entry)))
-   ((fx> tm
-	 (prio-queue-node-index ##sys#timeout-list-head))
+   ((timeout< (prio-queue-node-index ##sys#timeout-list-head) tm)
 (let ((entry (timeout-queue-node-lookup ##sys#timeout-list tm)))
   (if entry
 	  (begin
@@ -346,8 +345,7 @@ EOF
 	  (let ((entry (make-timeout-list-entry tm (list t
 	(##sys#setslot t 4 entry)
 	(timeout-queue-node-insert! ##sys#timeout-list entry)
-   ((fx< tm
-	 (prio-queue-node-index ##sys#timeout-list-head))
+   ((timeout< tm (prio-queue-node-index ##sys#timeout-list-head))
 (timeout-queue-node-insert!
  ##sys#timeout-list ##sys#timeout-list-head)
 (let ((entry (make-timeout-list-entry tm (list t
@@ -535,7 +533,7 @@ dunno what to do
 	;; Sleep for the number of milliseconds of next thread
 	;; to wake up.
 	(let ((tmo (prio-queue-node-index (timeout-queue-next
-	  (##core#inline "C_msleep" (fxmax 0 (##core#inline "C_quickflonumtruncate" (fp- tmo now )
+	  (##core#inline "C_msleep" (fpmax 0 (##core#inline "C_quickflonumtruncate" (fp- tmo now )
 
 (define (##sys#thread-block-for-timeout! t tm)
   (dbg t " blocks for timeout " tm)
-- 
2.6.2

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] PATCH Re: slow polling

2016-02-20 Thread Jörg F . Wittenberger
Am 19.02.2016 um 22:39 schrieb Jörg F. Wittenberger:
> ...
>> I opened ticket 1259 for this.
>>
>> To make the kind reviewers job easier, I'll post diffs in piecemeal here.

This patch goes after killing a single - but important - comment line in
scheduler.scm:

;; This should really use a balanced tree:

Now it does.

This patch replaces the timeout queue with a balanced tree.


   It does not matter so much, which kind of tree we use.  But a
   linear list is really a bad choice.

   Assume you have a tcp-server alike: 100 client connections and
   you read the next input line.  It's probably (but not sure) already
   in the OS's buffer.  But chicken core will nevertheless establish a
   timeout.  The latter will so far traverse the (linear) timeout
   queue.  Chances are all those other timeouts are prior established
   reads using the same timeout too.  Thus you find the insert point
   right at the end.


If you have an application which makes heavy use of chicken's core tcp
unit (I don't use chicken's timeouts at all for this, I do use them, but
only via thread-sleep!) I'd be interested to hear how much good or bad
this patch does for you.

Cheers

/Jörg


From 38c2b03e6a96097fa4fd4eeb4971305d084ae90f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20F=2E=20Wittenberger?=
 
Date: Sat, 20 Feb 2016 18:13:49 +0100
Subject: [PATCH] Use balanced a tree for the timeout queue

---
 distribution/manifest |   1 +
 llrbtree.scm  | 505 ++
 scheduler.scm | 333 ++---
 3 files changed, 777 insertions(+), 62 deletions(-)
 create mode 100644 llrbtree.scm

diff --git a/distribution/manifest b/distribution/manifest
index 1dd037f..3fc253a 100644
--- a/distribution/manifest
+++ b/distribution/manifest
@@ -28,6 +28,7 @@ posixunix.c
 posixwin.c
 profiler.c
 scheduler.c
+llrbtree.scm
 srfi-69.c
 srfi-1.c
 srfi-13.c
diff --git a/llrbtree.scm b/llrbtree.scm
new file mode 100644
index 000..4b19e4d
--- /dev/null
+++ b/llrbtree.scm
@@ -0,0 +1,505 @@
+;; #!/usr/bin/csi
+;; (C) 2008, 2010, 2013 Jörg F. Wittenberger.
+
+;; Redistribution permitted under either GPL, LGPL or BSD style
+;; license.
+
+;; (use extras)
+
+;; Changes
+;; Rewritten from the 2008 version; now in syntax-rules.
+
+;;* Left Leaning Red Black Tree
+
+;;** Code Generator
+
+;; Generate LLRB trees within arbitrary datastructures.
+
+(define-syntax define-llrbtree/positional
+  (syntax-rules ()
+((_
+  ;; The "features" is a list of symbols to control code
+  ;; expansion.  "pure" expands to an implementation, which never
+  ;; updates nodes.  "ordered" will enforce total order among the
+  ;; element.  "leftmost" will include code to maintain a leftmost
+  ;; value of the tree (not recommended, may be removed).
+  features
+  ;; The "update*" syntax must accept a node structure and
+  ;; key-value pairs.  Keys are color:, left: and right:
+
+  ;; "update" : If feature "pure" is set, "update" must expand
+  ;; to a newly allocated node, otherwise is MUST expand to a
+  ;; side effect full update of the original node.
+  update
+  ;; The following identifiers are bound in the expanded code.
+  ;; Pass #f for procedures not to be expanded.
+  init-root-node!		;; defined
+  t-lookup			;; defined
+  t-min			;; defined
+  t-fold			;; defined
+  t-for-each		;; defined
+  t-insert			;; defined
+  t-delete			;; defined
+  t-delete-min		;; defined
+  t-empty?			;; defined
+
+  ;; These syntax is used expand to code for comparision
+  ;; expressions.
+  t-k-eq?			;; key<>node-key "equal"
+  t-eq?			;; node-key<>node-key "equal"
+  t-k-node-key "less then"
+  t-node "less then"
+
+  ;; set-left!, set-right! and set-color! are unused, obsolete and
+  ;; will be removed in future version.
+  left set-left!
+  right set-right!
+  color set-color!
+  )
+ (begin
+   (define-syntax if/pure
+	 (syntax-rules (pure)
+	   ((_ kt kf) (if/pure features kt kf))
+	   ((_ () kt kf) kf)
+	   ((_ (pure . more) kt kf) kt)
+	   ((_ (kw . more) kt kf) (if/pure more kt kf
+
+   (define-syntax if/ordered
+	 (syntax-rules (ordered)
+	   ((_ kt kf) (if/ordered features kt kf))
+	   ((_ () kt kf) kf)
+	   ((_ (ordered . more) kt kf) kt)
+	   ((_ (kw . more) kt kf) (if/ordered more kt kf
+
+   (define-syntax if/leftmost
+	 (syntax-rules (leftmost)
+	   ((_ kt kf) (if/leftmost features kt kf))
+	   ((_ () kt kf) kf)
+	   ((_ (leftmost . more) kt kf) kt)
+	   ((_ (kw . more) kt kf) (if/leftmost more kt kf
+
+   (define-syntax cond-define
+	 (syntax-rules ()
+	   ((_ (#f . params) . body) #f)
+	   ((_ (id . params) . body)
+	(define (id . params) . body
+
+   (define-syntax root-node (syntax-rules () ((_ x) (left x
+
+#|
+Root pointers not yet working.
+   (define-syntax empty?
+	 (syntax-rules () ((_ t n) 

Re: [Chicken-hackers] PATCH fixing to recent changes to parameterize

2016-02-20 Thread Peter Bex
On Tue, Feb 16, 2016 at 09:55:50AM +1300, Evan Hanson wrote:
> Hi folks,
> 
> On 2016-02-15 21:22, Jörg F. Wittenberger wrote:
> > Yes: it is just to avoid the scrunity message.
> > 
> > However: it is not only a message.  It results in "some types not
> > satisfying type strictness" (or similar) and aborted compilation.
> 
> Indeed. How about the attached patch? It allows compatible types, rather
> than just subtypes, to allow just the sort of thing you're doing here.
> Then that hack with the lambda can be dropped.

Pushed, along with the parameterize change.  I also had to tweak your
patch a little bit because it changed one message that's written when
compiling scrutiny-test.scm, and removed another.  Finally, the
chicken-5 patch incorrectly changed "strict" back to
"strict-variable-types" so I had to fix that as well.

Cheers,
Peter


signature.asc
Description: Digital signature
___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers