-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Deserialization performance can be drastically improved by caching the list of builder methods. Here's a typical flame chart for reading mavlink messages in a loop:

You can see that sorting the builder methods takes almost half the deserialization time. This can easily be solved with:
private static final Map<Class<?>, List<Method>> builderMethodsCache = Collections.synchronizedMap(new HashMap<>());
private static List<Method> getBuilderMethods(Class<?> builderClass){
return builderMethodsCache.computeIfAbsent(builderClass, (c) -> Arrays.stream(c.getMethods())
.filter(m -> m.isAnnotationPresent(MavlinkFieldInfo.class))
.sorted((a, b) -> {
MavlinkFieldInfo fa = a.getAnnotation(MavlinkFieldInfo.class);
MavlinkFieldInfo fb = b.getAnnotation(MavlinkFieldInfo.class);
return wireComparator.compare(fa, fb);
}).collect(Collectors.toList()));
}
in ReflectionPayloadDeserializer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels