Breaking change: using LongAdder instead of AtomicLong by dfa1 · Pull Request #186 · graphql-java/java-dataloader

@dfa1

This is intended as proposal for #140

@dfa1 dfa1 mentioned this pull request

Apr 14, 2025

@dfa1

Use `LongAdder` instead of `AtomicLong`, that is
more suitable for high contention (see the javadoc).

bbakerman

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;

public class AtomicVsAdder {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in future a JMH benchmark is way better - we have them in dataloader recently

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, if you don't mind, I would like to drop this class as LongAdder is well-known class in JDK built exactly for this use case

bbakerman

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets do it