Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt out of the TypeFactory cache until we can resolve cache contention #2595

Merged
merged 2 commits into from
Apr 13, 2023

Conversation

carterkozak
Copy link
Contributor

Before this PR

FasterXML/jackson-databind#3876
FasterXML/jackson-benchmarks#5

The linked benchmarks show a small advantage of caching over not caching in most cases, in the best case for a cache: when a single operation is repeatedly executed. In practice, the cache is used for all operations and sees heavy evictions, where contention is more likely and has greater impact on users.

Given the hash collision issues that we're aware of, and the impacts we've observed, we will remove the cache until a version is available which isn't impacted by the linked issue for performance that's more predictable.

After this PR

==COMMIT_MSG==
Opt out of the TypeFactory cache until we can resolve cache contention
==COMMIT_MSG==

Possible downsides?

No caching may result in worse performance in the best cases, but avoids cross-thread contention on overloaded buckets which result in exceedingly long operations.

FasterXML/jackson-databind#3876
FasterXML/jackson-benchmarks#5

The linked benchmarks show a small advantage of caching over
not caching in most cases, in the best case for a cache: when
a single operation is repetedly executed. In practice, the cache
is used for all operations and sees heavy evictions, where contention
is more likely and has greater impact on users.

Given the hash collision issues that we're aware of, and the impacts
we've observed, we will remove the cache until a version is available
which isn't impacted by the linked issue for performance that's
more predictable.
@changelog-app
Copy link

changelog-app bot commented Apr 12, 2023

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Opt out of the TypeFactory cache until we can resolve cache contention

Check the box to generate changelog(s)

  • Generate changelog entry


@Override
public NonCachingTypeFactory withModifier(TypeModifier mod) {
return new NonCachingTypeFactory(_parser, computeModifiers(_modifiers, mod), _classLoader);
Copy link
Contributor

Choose a reason for hiding this comment

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

Meta-non-actionable observation: the _modifiers and _classloader prefixed with _ threw me at first as I forgot that's the Jackson protected field style.

@schlosna
Copy link
Contributor

Based on the benchmarks and profiles I have seen, this tradeoff seems right for now to avoid the major contention and ConcurrentHashMap bin traversals on high throughput code paths.

@carterkozak carterkozak marked this pull request as ready for review April 13, 2023 13:36
@bulldozer-bot bulldozer-bot bot merged commit 58623f6 into develop Apr 13, 2023
@bulldozer-bot bulldozer-bot bot deleted the ckozak/opt_out_of_jackson_typefactory_cache branch April 13, 2023 13:36
@svc-autorelease
Copy link
Collaborator

Released 7.50.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants