avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Performance bottleneck at RecordNaming #151

Closed twinprime closed 2 months ago

twinprime commented 11 months ago

Hi, I am not sure if this is a known problem.

I was doing a simple benchmark of Avro4k and discovered that when Unions are involved, e.g. a sealed interface, a lot of CPU time (like 30% for my case) is spent on RecordNaming.invoke(String, List<Annotation>, NamingStrategy). I used VisualVM to verify.

This is one of the thing that makes Avro4K much slower than jackson-dataformat-avro. Its 2-3x slower for my test case.

Chuckame commented 11 months ago

Thanks for the benchmark. Can you put at least a screenshot of visualvm of CPU Time tab, or at most the file ? Also with source showing the benchmark if possible

We know that there is still reflection that could be replaced, and a lot of re-computation on some cases.

twinprime commented 11 months ago

No problem, I uploaded the src and a screen shot here

https://github.com/twinprime/avro-benchmark

Chuckame commented 11 months ago

Thanks. I'll try to fix this

Chuckame commented 10 months ago

I'm currently working on #148 that should improve the performances, I'll let you informed

thake commented 5 months ago

A huge performance improvement is planned for version 2. See https://github.com/avro-kotlin/avro4k/issues/160#issuecomment-1711616190

Chuckame commented 2 months ago

Duplicate of #199

Chuckame commented 1 month ago

FYI @twinprime I just move your project to avro4k to allow us benchmarking easily for the next releases, thanks for the codebase. See #208