Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

ADPPRG-126821: Reduce contention in access to pdx registry #6

Open
wants to merge 6 commits into
base: release-nordix/1.15.1
Choose a base branch
from

Conversation

albertogpz
Copy link
Collaborator

@albertogpz albertogpz commented Dec 28, 2022

Access to the Geode predefined types in the
serialization registry has been changed from a
mutex synchronized map to a hardwired switch-case
in order to avoid contention when several threads
access them.

 - Whenever execution server functions with isHA=false, hasResult=true
   and optimizeForWrite=true, if the metadata is incomplete a request of
   type EXECUTE_REGION_FUNCTION_SINGLE_HOP is sent with an invalid
   bucket set partition. This causes an
   InternalFunctionInvocationTargetException exception
 - In order to solve this issue, now, whenever calling
   groupByServerToBuckets, if there isn't a valid location for one of
   the buckets, it returns nullptr, triggering the fallback mechanism
   which would be sending EXECUTE_REGION_FUNCTION to one of the nodes
   instead.
 - Moved PUT actions from LocalRegion into its own modules.
 - Added PutIfAbsent action.
 - Added the necessary scaffolding for put requests to return a value.
 - Moved TcrMessagePut implementation into its own file. Now this message
   type accepts an operation as input.
 - Moved TcrMessageDestroy implementation into its own file. Now this
   message accepts an operation as input.
 - Also, updated TcrMessageDestroy operation format so it uses a byte
   part instead of an object.
 - Added putIfAbsent method to the Region interface and its
   implementations both for LocalRegion and ThinClientRegion.
 - Modified LocalRegion and ThinClientRegion to comply with the above
   code changes.
 - Modified PUT's old value parsing to handle null pointer.
 - Also replaced Cacheable type by Serializable in some places in order
   to take advantage of fast-forward definition.
Copy link
Collaborator

@gaussianrecurrence gaussianrecurrence left a comment

Choose a reason for hiding this comment

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

Also, about the commit message, the SerializationRegistry and TheTypeMap handles several different types, not just PdxTypes. PdxTypes are one of the types handled by these registries and in particular, the contention is not caused by PdxTypes.

const auto& found = dataSerializableFixedIdMap_.find(dsfid);
if (found != dataSerializableFixedIdMap_.end()) {
func = found->second;
switch (dsfid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This switch case should be in SerializationRegistry::deserializeDataSerializableFixedId and in default we should call to TheTypeMap::findDataSerializableFixedId. IMHO, TheTypeMap should be strictly focused for user-defined types, not internally library pre-defined types

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I agree.

func = found->second;
// Geode builtins will be inside the switch value cases.
// The type ids should be in DSCode.hpp
switch (dsCode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to modify this function, since the only calling function, SerializationRegistry::serialize, is already handling library pre-defined types, and there is no other call point. Hence, this function will be only called if the type we are looking for is an user-defined type

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Thanks for pointing it out.


theTypeMap_.findDataSerializablePrimitive(dsCode, createType);
if (createType == nullptr) {
theTypeMap_.findDataSerializablePrimitive(dsCode, createType);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better if this is handled in the default case of above's switch, making it more clear this handles user-defined types and avoiding the need to make the null comparison

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree.

Access to the Geode predefined types in the
serialization registry has been changed from a
mutex synchronized map to a hardwired switch-case
in order to avoid contention when several threads
access them.
Final commit must be modified as follows:
Access to the Geode predefined types in the
serialization registry has been changed from a
mutex synchronized map to a hardwired switch-case
in order to avoid contention when several threads
access them.
if (found != dataSerializableFixedIdMap_.end()) {
func = found->second;
}
const std::lock_guard<std::mutex> guard(dataSerializableFixedIdMapMutex_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clang formatting rules establish that 2 spaces should be used for indentation, I think you are using 4 here.

if (found != dataSerializablePrimitiveMap_.end()) {
func = found->second;
}
const std::lock_guard<std::mutex> guard(dataSerializablePrimitiveMapMutex_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Clang formatting rules establish that 2 spaces should be used for indentation, I think you are using 4 here.

@gaussianrecurrence gaussianrecurrence force-pushed the release-nordix/1.15.1 branch 2 times, most recently from 579afe9 to fb1a836 Compare January 9, 2023 15:45
Copy link
Collaborator

@gaussianrecurrence gaussianrecurrence left a comment

Choose a reason for hiding this comment

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

Apparently, after changing release-nordix/1.15.1, this requires a rebase

@metal3-io-bot
Copy link
Member

@albertogpz: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

Successfully merging this pull request may close these issues.

4 participants