-
Notifications
You must be signed in to change notification settings - Fork 232
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
S2755 Improve performance: XmlExternalEntityShouldNotBeParsed #4483
Comments
Hi @pfeigl, thanks for your feedback. As far as I can tell this issue and #4220 have the same root cause: we get symbols for all the identifiers and this is expensive. We can certainty improve in this regard. Depends on the fix but most probably, fixing #4220 will not fix this issue with Regarding the fix done in 8.23, it is only related to the utility analyzers and this explains why the problem is still reproducible. Once question though, did the analysis time improved for your project between previous version and 8.23? |
Hi @pfeigl, Can you provide a small sample of the file with many dictionary entries? With just one or two lines of the dictionary and total number of lines? You can change all type names, all constants to 42, string literals to "something" and so on. We just need to see anonymized form of the syntax you use, while keeping all syntax elements (number of keywords, braces, ...). |
Thanks for the feedback. We also suspected that the dictionary might still be somehow connected. We meanwhile changed the huge dictionary to To answer the open question: Yes, integrating 8.23 actually brought the build times down from ~3h to ~2h. Also find a anaonymized and shortened version of the file in question below (in reality its 4200 lines): using System.Collections.Generic;
using System.Linq;
public class InformationContainer
{
public InformationContainer(string identifier, int x, int y)
{
Identifier = identifier;
X = x;
Y = y;
}
public string Identifier { get; }
public int X { get; }
public int Y { get; }
}
public static class LongDictionaryContainer
{
public static IDictionary<string, IList<InformationContainer>> LongDictionary = new Dictionary<string, IList<InformationContainer>>
{
{"1", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"2", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"3", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"4", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"5", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1) } },
{"6", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"7", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"8", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"9", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"10", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"11", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"12", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"13", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"14", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"15", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"16", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"17", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"18", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"19", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"20", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"21", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"22", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"23", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"24", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"25", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"26", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } },
{"27", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"28", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,1), new InformationContainer("Lorem Ipsum", 0,0) } },
{"29", new List<InformationContainer> { new InformationContainer("Lorem Ipsum", 0,0) } }
};
} Thanks for a great product and the rapid help! One final question from our side: We actually excluded the whole file using If yes, is there a way to exclude certain analyzers for a specific file? |
Currently We are currently considering different options for applying the exclusions at the analysis time but all seem to have different downsides. One of them being a performance hit for checking if the file name of the syntax tree matches the exclusions pattern each time a Roslyn action is triggered :) The specification is currently in progress. One work around for this is to use |
Description
We have a single assembly which takes very long when beeing analyzed.
/p:reportanalyzer=true
shows the following resultRepro steps
For now I'm unable to share the source code :-( Some things that might stand out and give you some hints:
<Property Name="sonar.exclusions">**/*.xml,**/*.xsd</Property>
Known workarounds
We didn't find one (except ofcourse excluding the whole project, but that shouldn't be an option ;-) )
Related information
The text was updated successfully, but these errors were encountered: