I also believe it can multiple any potential issues with resources leakage. Not sure yet what is causing this but working with a Rails user that sees this:
I wrote a little script that creates 100k threads and can report 3.3.3 allocates way more memory than 3.2.x
3.2.2 - Memory allocated: 49603264 bytes
3.3.3 - Memory allocated: 104926404080 bytes
Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN to 3.1: DONTNEED, 3.2: DONTNEED, 3.3: UNKNOWN
be1bbd5b7d40ad863ab35097765d3754726bbd54 very explicitly removes the cache. What's unclear is whether it was intended, or if the intent was to reimplement it differently and it was forgotten.
Not sure if related but here's a benchmark of the impact (written by Gordon Chan):
#!/usr/bin/env ruby# Disable GC during the benchmarkGC.disable# Get the current memory usagemem_before=GC.stat[:malloc_increase_bytes]obj_before=GC.stat[:total_allocated_objects]# Perform the operation you want to benchmarkresult=100_000.times{Thread.new{}.join}# Get the new memory usage and object countmem_after=GC.stat[:malloc_increase_bytes]obj_after=GC.stat[:total_allocated_objects]# Re-enable GCGC.enableGC.stresssleep(5)# Calculate the memory and object allocation deltasmem_delta=mem_after-mem_beforeobj_delta=obj_after-obj_beforeputs"Memory allocated: #{mem_delta} bytes"puts"Objects allocated: #{obj_delta}"
It is. The thread cache was to reuse short lived thread and avoid all these allocations etc. Note however that it wasn't enabled on all platforms, so relying on it never really was a good idea.
It is. The thread cache was to reuse short lived thread and avoid all these allocations etc. Note however that it wasn't enabled on all platforms, so relying on it never really was a good idea.
I myself do not rely on this explicitly. It came up during a deeper investigation related to high memory usage / potential memory leaks of 3.3.x. We've been postponing the deployment of 3.3 due to much higher memory usage than 3.2 and this is one of the things that came up. As of now I am trying to identify short-lived thread usage amongst other Ruby OSS gems.