Skip to content

Conversation

@jbachorik
Copy link
Collaborator

See #539

@jbachorik jbachorik added this to the 2.2.3 milestone May 28, 2022
@jbachorik jbachorik self-assigned this May 28, 2022
@jbachorik jbachorik force-pushed the jb/lockfree_classcache branch from 6f0eed2 to c896518 Compare May 28, 2022 20:57
}

private static String getClKey(ClassLoader cl) {
return cl.getClass().getName() + "@" + System.identityHashCode(cl);

Choose a reason for hiding this comment

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

Think use Pair is better than concatenate string for key

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this wold be the right thing to do. Once I have your confirmation that this actually resolves your problems I will polish this PR.
Anyway, thanks for chiming in! Not a lot of feedback on PRs here usually ...

return bootstrapInfos;
}
Map<ClassName, ClassInfo> infos = cacheMap.computeIfAbsent(cl, k -> new HashMap<>(500));
boolean[] rslt = new boolean[] {false};

Choose a reason for hiding this comment

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

Would AtomicBoolean be better

Copy link
Collaborator Author

@jbachorik jbachorik May 31, 2022

Choose a reason for hiding this comment

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

This might be questionable - atomic boolean adds the overhead of CAS handling and since the value is updated and read from the same thread we don't need to enforce the visibility of the changed value and the final array might be fine.
TBH, not sure what the diff in the performance would be (if any) without profiling first but I used to use this pattern when multithreaded access was not required.

Choose a reason for hiding this comment

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

agreed, though i am more curious why boolean[] instead of boolean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The flag is changed from within a lambda. For that the variable needs to be effectively final.
If it were just a boolean then being effectively final would prevent changing the value.
A final, single element array is working around this limitation.

@jbachorik jbachorik force-pushed the jb/lockfree_classcache branch from 8b9f041 to bca084f Compare July 4, 2022 19:26
@jbachorik jbachorik merged commit febaef3 into develop Jul 4, 2022
@jbachorik jbachorik deleted the jb/lockfree_classcache branch July 4, 2022 19:38
@jbachorik jbachorik modified the milestones: 2.2.3, 2.3.0 Jul 9, 2022
@jbachorik jbachorik modified the milestones: 2.3.0, 2.2.3 Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants