junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
777 stars 112 forks source link

[PERFORMANCE] [BUG] @EntityId Annotation creates a lot of garbage over time #654

Open BambooBandit opened 2 years ago

BambooBandit commented 2 years ago

I noticed that after adding the @EntityId annotation to this component class

final public class EntityClusterChildCom extends Component
{
    @EntityId public int parentID;
    public boolean top;
}

my game started to generate a lot of garbage, inducing a GC once per minute. javaw_eJ4kH8oCSl

When I removed the annotation, the GC's dropped down to occuring .13 times per minute javaw_7AquySKgaN

visualVM says that all the garbage is Integer javaw_7Od7eScv6K

This behavior seems strange and unintentional, so I thought I would let y'all know. For reference, this component is created 18949 times, Artemis version 2.3.0.

EDIT I think i boiled the issue down to this specific line of code. https://github.com/junkdog/artemis-odb/blob/51628b3d316a2db1c1a7218572d03c56f2c98b0c/artemis-core/artemis/src/main/java/com/artemis/link/IntFieldMutator.java#L12 Is there anything that can be done to remove this typecasting?