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

process locations jit #328

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class CompiledExpressionInvoker
private readonly IList<LocationReference> _locationReferences;
private CodeActivityMetadata _metadata;
private CodeActivityPublicEnvironmentAccessor _accessor;
private bool _locationsInitialized;

public CompiledExpressionInvoker(ITextExpression expression, bool isReference, CodeActivityMetadata metadata)
{
Expand All @@ -40,7 +41,10 @@ public CompiledExpressionInvoker(ITextExpression expression, bool isReference, C

_metadataRoot = metadata.Environment.Root;

ProcessLocationReferences();
if (!metadata.Environment.IsValidating)
Copy link
Collaborator

@gabriela-lungu-uip gabriela-lungu-uip Jun 18, 2024

Choose a reason for hiding this comment

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

IsValidating is default false;
I can be set to true only in InternalActivityValidationServices constructor which is only called from Studio code either directly or indirectly. It is not called from anywhere in the production Robot code or Activities repository production code.
So the changes described in this PR do not affect the Robot.
In regards to the problem being fixed, this should be assessed by @aoltean16 or someone else from the Studio team

Copy link
Collaborator Author

@AndreiSingeorzan AndreiSingeorzan Jun 18, 2024

Choose a reason for hiding this comment

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

I've already asked for review from Alex, but as a general principle, this can also be reproduced in a simple unit test in this project (create a model item with 1400 variables and validate it with/without the ForceExpressionCache flag and observe the memory).

{
ProcessLocationReferences();
}
}

public object InvokeExpression(ActivityContext activityContext)
Expand All @@ -50,6 +54,11 @@ public object InvokeExpression(ActivityContext activityContext)
throw FxTrace.Exception.ArgumentNull(nameof(activityContext));
}

if (!_locationsInitialized)
{
ProcessLocationReferences();
}

if (_compiledRoot == null || _expressionId < 0)
{
if (!TryGetCompiledExpressionRoot(_expressionActivity, _metadataRoot, out _compiledRoot) ||
Expand Down Expand Up @@ -154,6 +163,11 @@ internal static bool TryGetCompiledExpressionRoot(Activity target, bool forImple

internal Expression GetExpressionTree()
{
if (!_locationsInitialized)
{
ProcessLocationReferences();
}

if (_compiledRoot == null || _expressionId < 0)
{
if (!TryGetCompiledExpressionRootAtDesignTime(_expressionActivity, _metadataRoot, out _compiledRoot, out _expressionId))
Expand Down Expand Up @@ -198,6 +212,8 @@ private bool CanExecuteExpression(ICompiledExpressionRoot compiledExpressionRoot

private void ProcessLocationReferences()
{
_locationsInitialized = true;

Stack<LocationReferenceEnvironment> environments = new();
//
// Build list of location by enumerating environments
Expand Down