ThreadRecycler
A thread management module strictly written in Luau.
Moved
(Currently unlisted after a recent benchmark using Benchmaker. I may request this to be public again after I fix the issues?)
GitHub Repo | Documentation & Tutorial | Releases | Last updated: 2/4/25
Performance
ThreadRecycler optimizes thread usage by recycling and reusing it, which reduces resource consumption. Fewer resources are wasted on unnecessary threads, which leads to faster execution.
Limitations
- Must replace
task.wait()
withThreadRecycler.wait()
to prevent issues in the task library (more context in the documentation. However, if you only useThreadRecycler.wrap()
, this step might not be necessary. - Using
ThreadRecycler.defer()
andThreadRecycler.delay()
isn’t broken per se, but due to task library issues, an alternative is strongly recommended.- (Possible warning if used) “task.defer should not be called on a thread that is already ‘deferred’ in the task library”
- As this is my first open-source and public module, it may require significant improvements.
Benchmarks
Figure
(Note: I don’t really know how to accurately benchmark this module, haven’t done a benchmark before. The problem with the benchmarking I did is that more threads are created if the heartbeat rate is lower as I have it under a while loop.)
Input (x): Workload | Output (y): Heartbeat time (s)
Workload in this case is property changes, networking, and calculations.
Full benchmark results are in the documentation.
Installation (via GitHub Releases)
Head over to releases and download the .rbxm
file from the latest version. Then, insert the .rbxm
file into Roblox Studio.
Require the module:
local ThreadRecycler = require(game.GetService(game, "ReplicatedStorage").ThreadRecycler)
I strongly recommend that you use the documentation for more in-depth details.
License
ThreadRecycler is fully open-source and free to use with a MIT license.
Contributions
All contributions are welcome! :)