Skip to content

Performance degradation in Java from duplicate warnings check #23963

@tkruse

Description

@tkruse

What version of protobuf and what language are you using?
Version: main/v3.25.8
Language: Java

What operating system (Linux, Windows, ...) and version?
Linux

What runtime / compiler are you using (e.g., python version or gcc version)
Java17

What did you do?
On a Java webServer producing a lot of protoc2 messages, upgrade from 3.25.3 to 3.25.8

What did you expect to see
No functional change

What did you see instead?
Degraded performance, pinpointed to thread contention for method call Set.add in this code

private static final Set<String> loggedPre22TypeNames
      = Collections.synchronizedSet(new HashSet<String>()); // <-- synchronizedSet causing locking

static void warnPre22Gencode(Class<?> messageClass) {
    // ...
    if (!loggedPre22TypeNames.add(messageName)) {   //   <---- thread contention here
       return;
    }
    logger.warning(vulnerabilityMessage);
}

Related changes:

CC @esrauchg @zhangskz

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedauto added to all issues by default when created.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions