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 c6526df..24786b6 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 only work 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 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 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 49d93ea..d93caaa 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 only work 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 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](https://github.com/andersmurphy/clj-cookbook/tree/master/virtual-threads/dynamic-var-perf).