eclipse-ee4j / grizzly

Grizzly
https://eclipse-ee4j.github.io/grizzly
Other
146 stars 68 forks source link

Avoid using ThreadLocals for caching expensive resources #2206

Open OndroMih opened 4 months ago

OndroMih commented 4 months ago

In order to avoid performance degradation when using virtual threads (see https://github.com/eclipse-ee4j/grizzly/pull/2185), usage of thread locals for caching resources should be minimized or completely avoided.

Acording to the comment https://github.com/eclipse-ee4j/grizzly/pull/2185#issuecomment-1787016453, there are a few ThreadLocal variables used as cache:

Thread cache:

Some variables potentially used for caching - if not used for caching, may remain as is:

Thread-unsafe formatters cached for performance purposes - these should be replaced by global DateTimeFormatter instances, which is thread-safe and can be reused by multiple threads:

laurentschoelens commented 4 months ago

@OndroMih : working on this issue