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

Introduce cache for process versions #12475

Merged
merged 2 commits into from
Apr 20, 2023

Conversation

Zelldon
Copy link
Member

@Zelldon Zelldon commented Apr 18, 2023

Description

When executing a process instance we often have to get the process model and related version to it.

When running a cluster for a while (creating a lot of state etc.) the process version will eventually be migrated to a low level of RocksDB (potentially L3), because most of the time process models are not deployed that often. In other words, if a key is not updated it will be moved to a lower level by RocksDB. Accessing lower levels of RocksDB is slower than accessing higher levels or mem tables.

You might ask why is it slow, even if we repeatedly access via RocksDB, why is it not in the cache? There are multiple reasons for it.

  1. We only have caches for L0, and L1 configured (not for lower levels)
  2. We have limited the cache sizes to a certain amount which might cause continuous eviction

In order to avoid running into issues with cold data, which is mostly static data, we can introduce our own caches, to work around this. This allows us to avoid unnecessary RocksDB access, unnecessary io, etc.

This PR does the following:

  • Refactors the NextValueManager, including renaming as its only purpose is to be used for ProcessVersions
  • Introduce a new cache for the version of each process, in order to avoid access to cold data.

Performance:

We run again a JMH benchmark with the changes and can see that the performance slightly increased (potentially 8%), not significant but it will likely come into play with other changes later.

See more details here

Related issues

closes #12034

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Other teams:
If the change impacts another team an issue has been created for this team, explaining what they need to do to support this change.

Please refer to our review guidelines.

@Zelldon Zelldon changed the title Zell meg 12033 cache versions Cache mostly static data Apr 18, 2023
@Zelldon Zelldon changed the title Cache mostly static data Introduce cache for process versions Apr 18, 2023
@Zelldon Zelldon force-pushed the zell-meg-12033-cache-versions branch from 594bb6d to 5fcea5d Compare April 18, 2023 15:09
In order to avoid confusion rename NextValueManager
to ProcessVersionManager, since it is only purpose is
to manage the version of a process.
In order to avoid unnecessary RocksDB access,
we introduce an cache for the process version.

The version is likely to not change too often,
which will cause it to move to a low layer in
RocksDB, which might make access slow in the hot
path.
@Zelldon
Copy link
Member Author

Zelldon commented Apr 19, 2023

Just for posterity:

Today we had a sync PR review with @berkaycanbc and @koevskinikola where I explained all the details and reasoning behind it. We had a good discussion where I also was able to answer some open questions.

There was no blocker found during this call, so I expect we can go ahead to merge the PR after it is accepted by any of the reviewers.

Copy link
Contributor

@megglos megglos left a comment

Choose a reason for hiding this comment

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

LGTM!

@megglos megglos added backport stable/8.1 backport stable/8.2 Backport a pull request to 8.2.x labels Apr 20, 2023
@megglos
Copy link
Contributor

megglos commented Apr 20, 2023

bors r+

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit 59d5639 into main Apr 20, 2023
32 checks passed
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the zell-meg-12033-cache-versions branch April 20, 2023 08:28
@backport-action
Copy link
Collaborator

Backport failed for stable/8.1, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin stable/8.1
git worktree add -d .worktree/backport-12475-to-stable/8.1 origin/stable/8.1
cd .worktree/backport-12475-to-stable/8.1
git checkout -b backport-12475-to-stable/8.1
ancref=$(git merge-base 9dbedea61c4e96297ee9076c159d0902195d9257 743bec2ca5c74372c3d0d359106d06396c41b008)
git cherry-pick -x $ancref..743bec2ca5c74372c3d0d359106d06396c41b008

@backport-action
Copy link
Collaborator

Successfully created backport PR for stable/8.2:

zeebe-bors-camunda bot added a commit that referenced this pull request Apr 20, 2023
12495: [Backport stable/8.2] Introduce cache for process versions r=megglos a=backport-action

# Description
Backport of #12475 to `stable/8.2`.

relates to #12034

Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
zeebe-bors-camunda bot added a commit that referenced this pull request Apr 21, 2023
12496: [Backport stable/8.1] Introduce cache for process versions r=oleschoenburg a=megglos

# Description
Backport of #12475 to `stable/8.1`.

Note: This doesn't contain the rename commit ec2f789 of the NextValueManager to ProcessVersionManager, as `NextValueManager` is used in other occasions on the 8.1 branch.

relates to #12034

Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
@lenaschoenburg lenaschoenburg added version:8.2.3 Marks an issue as being completely or in parts released in 8.2.3 version:8.1.11 Marks an issue as being completely or in parts released in 8.1.11 labels Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport stable/8.2 Backport a pull request to 8.2.x version:8.1.11 Marks an issue as being completely or in parts released in 8.1.11 version:8.2.3 Marks an issue as being completely or in parts released in 8.2.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetching constantly static information
4 participants