Skip to content

Conversation

@theigl
Copy link
Collaborator

@theigl theigl commented Apr 19, 2023

This PR improves the default implementation of Kryo.isClosure() in two ways:

  1. Check if the type is synthetic
  2. Check if the simple name of the class contains a /

This is only slightly faster for hits, but significantly faster for misses:

Benchmark Mode Cnt Score Units
ClosureBenchmark.newHit thrpt 2 231402690,531 ops/s
ClosureBenchmark.oldHit thrpt 2 188889209,053 ops/s
ClosureBenchmark.newMiss thrpt 2 1796295832,164 ops/s
ClosureBenchmark.oldMiss thrpt 2 174581347,713 ops/s

I hope that Class.isSynthetic() is true for closures on all JDKs.

@theigl theigl self-assigned this Apr 19, 2023
@theigl theigl merged commit 8742e6e into master Apr 19, 2023
@theigl theigl deleted the faster-is-closure-check branch April 19, 2023 12:44
@theigl theigl mentioned this pull request Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants