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 noticed that using XElement.Load(stream, LoadOptions.SetLineInfo) is very slow and memory consuming is times 2 compared to XElement.Load(stream, LoadOptions.None)
See table. For the completeness, I also added the results for the generated for class (XSD to C#) - which is very fast and not using much memory but is lacking the lineinfo.
Tested it with a XML file of 914MB
Method
Memory
Time
XElement without lineinfo (LoadOptions.None)
2.213.541 Mb (2.271.092.736 bytes)
27 Sec (26.502 ms)
XElement with lineinfo (LoadOptions.SetLineInfo)
5.523.492 Mb (5.667.102.720 bytes)
46 Sec (45.781 ms)
Own "XElement" without lineinfo
2.825.026 Mb (2.898.477.056 bytes)
25 Sec (24.584 ms)
Own "XElement" with lineinfo
2.825.226 Mb (2.898.681.856 bytes)
26 Sec (25.969 ms)
XSD generated classes
845.057 Mb (867.028.992 bytes)
27 Sec (26.966 ms)
Own "XElement"
The funny part is that I wrote my own "XElement" in the past, and there is nearly no difference in capturing the lineInfo compared to non-capure. I'm doing for all element and all attributes XmlPosition.Create(reader):
using Process.GetCurrentProcess().WorkingSet64 for memory
using System.Diagnostics.StopWatch for timings
Env
Tested with .NET Core 2.2, Windows Server 2016 datacenter
The text was updated successfully, but these errors were encountered:
304NotModified
changed the title
XElement - LoadOptions.SetLineInfo - very slow
XElement - LoadOptions.SetLineInfo - very slow & memory times 2
Nov 22, 2019
@304NotModified this is something we would have to investigate. Do you have your xml file somewhere permanently available? Do you perhaps have perf logs with and without line info available to compare?
Would you be interested in doing the investigation/fixes?
PS. We have merged corefx and coreclr into dotnet/runtime repo so that's where the issue should be filed (it will get moved there eventually)
@304NotModified as an aside, we recommend using Benchmark.NET for profiling. This is what we use ourselves. Although, in this case the difference seems to be large enough that it doesn't matter...
Hi,
I noticed that using
XElement.Load(stream, LoadOptions.SetLineInfo)
is very slow and memory consuming is times 2 compared toXElement.Load(stream, LoadOptions.None)
See table. For the completeness, I also added the results for the generated for class (XSD to C#) - which is very fast and not using much memory but is lacking the lineinfo.
Tested it with a XML file of 914MB
LoadOptions.None
)LoadOptions.SetLineInfo
)Own "XElement"
The funny part is that I wrote my own "XElement" in the past, and there is nearly no difference in capturing the lineInfo compared to non-capure. I'm doing for all element and all attributes
XmlPosition.Create(reader)
:So I can't understand why the XElement is using so much memory/time for SetLineInfo!
XmlReaderSettings
PS: also tried, but no significant change.
Test
Process.GetCurrentProcess().WorkingSet64
for memoryEnv
Tested with .NET Core 2.2, Windows Server 2016 datacenter
The text was updated successfully, but these errors were encountered: