You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I met with a strange issue. methods-jitted-count counter increments infinitely if a project has a rule for a full request (not for a property of the request). And it is the only problem, I didn't notice problems with performance or something else.
The first time I saw the problem in my work project which worked with 80 RPS. But I also reproduce the problem in the example project.
Steps to Reproduce
Create a request with at least one property
public record Request(int? Property);
Create a validator with a rule for the request, not for property of request
public class RequestValidator : AbstractValidator<Request>
{
public RequestValidator() =>
RuleFor(request => request)
.Must((request) => request.Property.HasValue);
}
I'm afraid this isn't something that I have time or capacity to look into, so will need someone from the community to investigate further, sorry.
Edit: Oh it'll be because rules are only cached if they're defined against a property. If they're not defined against a property we can't cache them so the expression will have to be recompiled every time the validator is instantiated. If this is a problem for you then you should either rewrite your rule definition not to rely on the root level object, or make your validator singleton-scoped (provided it has no transient or request-scoped dependencies). Its possible we may be able to add caching for root-level expressions in the future, which I will investigate for the next release.
FluentValidation version
11.8.0
ASP.NET version
.NET 7
Summary
I met with a strange issue.
methods-jitted-count
counter increments infinitely if a project has a rule for a full request (not for a property of the request). And it is the only problem, I didn't notice problems with performance or something else.The first time I saw the problem in my work project which worked with 80 RPS. But I also reproduce the problem in the example project.
Steps to Reproduce
methods-jitted-count
counter in a terminal with the command. On my computer, it shows:Number of Methods Jitted - 1,830
Number of Methods Jitted - 2,311
Number of Methods Jitted - 2,411
Number of Methods Jitted - 2,512
. The counter will continue increment for every call.Expected result
methods-jitted-count
counter in a terminal with the command. On my computer, it shows:Number of Methods Jitted - 1,815
Number of Methods Jitted - 2,229
Number of Methods Jitted - 2,229
Also, I attached the project which I used to demonstrate the problem.
FluentValidationMethodJittedProblem.zip
The text was updated successfully, but these errors were encountered: