aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2025-02-04 12:52:12 +0000
committerChristopher Baines <mail@cbaines.net>2025-02-04 13:16:10 +0000
commita11cd24e57ad334c26700691dca0164f410cc392 (patch)
tree70431ab47ac4b651f7b9d991607be3307c3835d7 /tests
parentaadbee0d0e452670719d030e5a40ff115ba10c68 (diff)
downloadknots-a11cd24e57ad334c26700691dca0164f410cc392.tar
knots-a11cd24e57ad334c26700691dca0164f410cc392.tar.gz
Improve resource pool performance when there are lots of waiters
Diffstat (limited to 'tests')
-rw-r--r--tests/resource-pool.scm40
1 files changed, 33 insertions, 7 deletions
diff --git a/tests/resource-pool.scm b/tests/resource-pool.scm
index 50dadbd..cf108de 100644
--- a/tests/resource-pool.scm
+++ b/tests/resource-pool.scm
@@ -105,15 +105,41 @@
(error "collision detected")))
(new-number))
1)))
- (fibers-for-each
+ (fibers-batch-for-each
+ (lambda _
+ (with-resource-from-pool
+ resource-pool res
+ (let ((start-val counter))
+ (sleep 0.05)
+ (if (= start-val counter)
+ (set! counter (+ 1 counter))
+ (error "collision detected")))))
+ 20
+ (iota 50)))))
+
+(run-fibers-for-tests
+ (lambda ()
+ (let* ((counter 0)
+ (resource-pool (make-resource-pool
+ (lambda ()
+ (let ((start-val counter))
+ (sleep 0.05)
+ (if (= start-val counter)
+ (set! counter (+ 1 counter))
+ (error "collision detected")))
+ (new-number))
+ 1
+ #:reply-timeout #f)))
+ (fibers-batch-for-each
(lambda _
(with-resource-from-pool
- resource-pool res
- (let ((start-val counter))
- (sleep 0.05)
- (if (= start-val counter)
- (set! counter (+ 1 counter))
- (error "collision detected")))))
+ resource-pool res
+ (let ((start-val counter))
+ (sleep 0.05)
+ (if (= start-val counter)
+ (set! counter (+ 1 counter))
+ (error "collision detected")))))
+ 20
(iota 50)))))
(display "resource-pool test finished successfully\n")