From 1c5456325e7f46ba795baa6c8b354068fdb51029 Mon Sep 17 00:00:00 2001 From: andersmurphy Date: Thu, 30 May 2024 14:45:36 +0200 Subject: [PATCH] Minor copy change --- .../05/30/clojure-virtual-thread-dynamic-var-performance.html | 2 +- ...2024-05-30-clojure-virtual-thread-dynamic-var-performance.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/2024/05/30/clojure-virtual-thread-dynamic-var-performance.html b/docs/2024/05/30/clojure-virtual-thread-dynamic-var-performance.html index 24786b6..d56354a 100644 --- a/docs/2024/05/30/clojure-virtual-thread-dynamic-var-performance.html +++ b/docs/2024/05/30/clojure-virtual-thread-dynamic-var-performance.html @@ -90,4 +90,4 @@ ;; Execution time lower quantile : 165.292587 ms ( 2.5%) ;; Execution time upper quantile : 215.966794 ms (97.5%) ;; Overhead used : 1.845282 ns -

With 50000 virtual threads pmap's execution time mean is 189.313904 ms. Roughly, 5x faster than the dynamic var version and a similar speed to the scoped values version.

My take away is: you probably don't need dynamic scope. Instead, pass the context explicitly. If you really think you need dynamic scope and are using a large number of virtual threads favour scoped values over dynamic vars. That being said scoped values thread conveyance only works with structured concurrency, so if you are using things like Executor and CompletionService you'll have to either pass context explicitly or use dynamic vars.

The full example project can be found here.

Further Reading:

\ No newline at end of file +

With 50000 virtual threads pmap's execution time mean is 189.313904 ms. Roughly, 5x faster than the dynamic var version and a similar speed to the scoped values version.

My take away is: you probably don't need dynamic scope. Instead, pass the context explicitly. If you really think you need dynamic scope and are using a large number of virtual threads favour scoped values over dynamic vars. That being said thread conveyance for scoped values only works in the context structured concurrency, so if you are using things like Executor and CompletionService you'll have to either pass context explicitly or use dynamic vars.

The full example project can be found here.

Further Reading:

\ No newline at end of file diff --git a/resources/posts/2024-05-30-clojure-virtual-thread-dynamic-var-performance.md b/resources/posts/2024-05-30-clojure-virtual-thread-dynamic-var-performance.md index d93caaa..ad7ea17 100644 --- a/resources/posts/2024-05-30-clojure-virtual-thread-dynamic-var-performance.md +++ b/resources/posts/2024-05-30-clojure-virtual-thread-dynamic-var-performance.md @@ -141,7 +141,7 @@ If your function call stack is shallow then, it can be simpler to just pass the With 50000 virtual threads `pmap`'s execution time mean is 189.313904 ms. Roughly, 5x faster than the dynamic var version and a similar speed to the scoped values version. -My take away is: you probably don't need dynamic scope. Instead, pass the context explicitly. If you really think you need dynamic scope and are using a large number of virtual threads favour scoped values over dynamic vars. That being said scoped values thread conveyance only works with structured concurrency, so if you are using things like `Executor` and `CompletionService` you'll have to either pass context explicitly or use dynamic vars. +My take away is: you probably don't need dynamic scope. Instead, pass the context explicitly. If you really think you need dynamic scope and are using a large number of virtual threads favour scoped values over dynamic vars. That being said thread conveyance for scoped values only works in the context structured concurrency, so if you are using things like `Executor` and `CompletionService` you'll have to either pass context explicitly or use dynamic vars. The full example [project can be found here](https://github.com/andersmurphy/clj-cookbook/tree/master/virtual-threads/dynamic-var-perf).