Skip to content

ST6RI-944 Invalidate TypeAdapter#getFeatureMembership cache when needed - #773

Open
AxelRICHARD wants to merge 3 commits into
masterfrom
ST6RI-944
Open

ST6RI-944 Invalidate TypeAdapter#getFeatureMembership cache when needed#773
AxelRICHARD wants to merge 3 commits into
masterfrom
ST6RI-944

Conversation

@AxelRICHARD

@AxelRICHARD AxelRICHARD commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a bug such that, after an initial call to getFeatureMembership on a Type element, if additional FeatureMemberships are added, they were not being reflected in subsequent calls to getFeatureMembership.

Background

PR #749 (ST6RI-925) introduced caching in TypeAdapter for featureMemberships. This caching happens on the first call to getFeatureMembership. After this, unless the cache is cleared, getFeatureMemberships always returns the cached value, even if new FeatureMembership relationships have been added to the source element.

The following methods directly or indirectly use getFeatureMembership and,so, also reflect this bug:

  • Type.getFeature, getDirectedFeature, getEndFeature, getInput, getOutput
  • InstantiationExpression.getArgument
  • ConnectionDefinition.getConnectionEnd
  • InterfaceDefinition.getInterfaceEnd

Note. Association.getAssociationEnd, Connector.getConnectorEnd and FlowDefinition.getFlowEnd and FlowUsage.getConnectorEnd have the same functionality as getEndFeature.

Changes

For each of the methods above, define a corresponding static utility method. The original property methods are re-implemented to first call ElementUtil.clearCache on the method argument, then call the corresponding utility method. Internally, the utility methods are used directly to allow caching to improve performance.

Property Getter Method Utility Method
Type.getFeatureMembership TypeUtil.getFeatureMembershipOf
Type.getFeature TypeUtil.getFeatureOf
Type.getDirectedFeature TypeUtil.getDirectedFeatureOf
Type.getEndFeature TypeUtil.getEndFeatureOf
Type.getInput TypeUtil.getInputOf
Type.getOutput TypeUtil.getOutputOf
InstantiationExpression.getArgument ExpressionUtil.getArgumentOf
ConnectionDefinition.getConnectionEnd UsageUtil.getConnectionEndOf
InterfaceDefinition.getInterfaceEnd UsageUtil.getInterfaceEndOf

With this approach, performance (as measured using SysMLInteractiveProfiler) is essentially the same as before the changes in this PR. Without caching, there is a performance degradation of 10 to 20%.

@AxelRICHARD AxelRICHARD added the bug Something isn't working label Jun 22, 2026
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
@seidewitz
seidewitz force-pushed the master branch 2 times, most recently from 00acc2f to 2a8e96c Compare July 2, 2026 08:31
@AxelRICHARD AxelRICHARD changed the title ST6RI-944 Revert TypeAdapter#getFeatureMembership cache ST6RI-944 Invalid TypeAdapter#getFeatureMembership cache when needed Jul 7, 2026
@AxelRICHARD

Copy link
Copy Markdown
Contributor Author

Hello @seidewitz do you need something else for this pull request? If no, can I set it as "Ready for review"?

@seidewitz seidewitz self-assigned this Aug 12, 2026
@AxelRICHARD
AxelRICHARD marked this pull request as ready for review August 26, 2026 06:50
@AxelRICHARD AxelRICHARD added this to the 2026-08 milestone Aug 26, 2026
@seidewitz seidewitz changed the title ST6RI-944 Invalid TypeAdapter#getFeatureMembership cache when needed ST6RI-944 Invalidate TypeAdapter#getFeatureMembership cache when needed Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants