Fabric API

Fabric API

108M Downloads

An idea for more efficient lookup of static state tracked by a specific game thread

i509VCB opened this issue ยท 3 comments

commented

I've seen use of ThreadLocal be quite common in mixins. However I believe most uses of that are only done on the render and server thread which is a little bit overkill for ThreadLocal which is effectively a Map<Thread, T>.

So I had the idea of introducing a new holder type I call SideThreaded. In use and provided api would be similar to ThreadLocal but it only tracks a value on the server or client thread, resulting in a potentially more efficient lookup than ThreadLocal.

Does the idea of SideThreaded improve lookup speeds by a large amount? Who knows, I just had an idea so I made it.

commented

Interesting idea, but I don't think it's going to be used in practice.

commented

What... The true way to fix is imo is to hack into stack map frame and add local variables. They are thread safe as opposed to fields.

commented

Well in any case someone would have to provide a sampler result where ThreadLocal overhead is clearly visible.