Skip to content

Conversation

@apmoriarty
Copy link
Collaborator

  • TypeFactory now uses a CaffeineCache
  • Document, Attributes, Content use a ThreadLocal Caffeine cache found in the Attribute class
  • Updated DocumentSerializationIT for better coverage

protected long sizeInBytes = Long.MIN_VALUE;

// used by Document, Attributes and TypeAttribute
protected static final ThreadLocal<ClassCache> classCache = ThreadLocal.withInitial(CaffeineClassCache::new);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious why its thread local. Off the top of my head it sounds like it'd be better to share across all threads since we're still gonna end up doing reflection on each thread. Is it to remove contention?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct. Even though the Caffeine cache won out on performance there was still a lot of contention in an environment with lots of threads. Making this ThreadLocal improved the time to parse each document and reduced the overall wall clock time.

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.

4 participants