From be9989cf3d82659cee4814cce10093880b170faf Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 15 Feb 2008 14:16:28 -0600 Subject: [PATCH 1/2] More efficient io.unix.select --- extra/io/unix/select/select.factor | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/extra/io/unix/select/select.factor b/extra/io/unix/select/select.factor index 06e257a610..9827d4d54f 100755 --- a/extra/io/unix/select/select.factor +++ b/extra/io/unix/select/select.factor @@ -17,14 +17,18 @@ TUPLE: select-mx read-fdset write-fdset ; FD_SETSIZE 8 * over set-select-mx-read-fdset FD_SETSIZE 8 * over set-select-mx-write-fdset ; +: clear-nth ( n seq -- ? ) + [ nth ] 2keep f -rot set-nth ; + : handle-fd ( fd task fdset mx -- ) - roll munge rot nth [ swap handle-io-task ] [ 2drop ] if ; + roll munge rot clear-nth + [ swap handle-io-task ] [ 2drop ] if ; : handle-fdset ( tasks fdset mx -- ) [ handle-fd ] 2curry assoc-each ; : init-fdset ( tasks fdset -- ) - dup clear-bits + ! dup clear-bits [ >r drop t swap munge r> set-nth ] curry assoc-each ; : read-fdset/tasks @@ -33,13 +37,19 @@ TUPLE: select-mx read-fdset write-fdset ; : write-fdset/tasks { mx-writes select-mx-write-fdset } get-slots ; -: init-fdsets ( mx -- read write except ) +: max-fd dup assoc-empty? [ drop 0 ] [ keys supremum ] if ; + +: num-fds ( mx -- n ) + dup mx-reads max-fd swap mx-writes max-fd max 1+ ; + +: init-fdsets ( mx -- nfds read write except ) + [ num-fds ] keep [ read-fdset/tasks tuck init-fdset ] keep write-fdset/tasks tuck init-fdset f ; M: select-mx wait-for-events ( ms mx -- ) - swap >r FD_SETSIZE over init-fdsets r> make-timeval + swap >r dup init-fdsets r> make-timeval select multiplexer-error dup read-fdset/tasks pick handle-fdset dup write-fdset/tasks rot handle-fdset ; From 9faee652c89bdf852412359c9aa19b6cc66f8f8b Mon Sep 17 00:00:00 2001 From: sheeple Date: Fri, 15 Feb 2008 14:16:45 -0600 Subject: [PATCH 2/2] vocabs-profile. now omits type predicates --- extra/tools/profiler/profiler.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extra/tools/profiler/profiler.factor b/extra/tools/profiler/profiler.factor index 4702431a8f..c35d5a72c8 100755 --- a/extra/tools/profiler/profiler.factor +++ b/extra/tools/profiler/profiler.factor @@ -59,5 +59,7 @@ M: string (profile.) : vocabs-profile. ( -- ) "Call counts for all vocabularies:" print vocabs [ - dup words [ profile-counter ] map sum + dup words + [ "predicating" word-prop not ] subset + [ profile-counter ] map sum ] { } map>assoc counters. ;