DataSet.ReadXml is slow

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am moving some code over from the Desktop to Wince. One thing I noted was
that the funtion DataSet.ReadXml() takes quite a bit of time. Say about 2
minutes. This is using the Emulator. The Xml file that it reads is about
46kb. The program is being run under the Vs2003 debugger.

Is this normal or is something wrong?

Any suggestions would be appreciated.
 
I have not used the emulator to do this, but I have a VB .NET 2005 CF (beta)
application that reads in about 15 xml files (most are very small, but two of
these are 248 KB) and in the on-handheld debugger, on a Win CE .NET 4.2
handheld with a 520 MHZ processor and 64 MB RAM it only takes about a minute
to read in and update a SQLCE database with the data. I don't know how much
of a difference this makes, but, my dataset schema is pre-defined in a custom
dataset.xsd file, so the xml files contain data only...

sample code that reads in one xml file:
'CustomDataSet and Table Adapters
'are from a SQLCE Datasource previously
'attached to the project
Dim xmlFileName as String = "\Path\File.xml"
Dim fsReadXML As New System.IO.FileStream(xmlFileName, IO.FileMode.Open)
Dim dta As New CustomDataSetTableAdapters.UserTableAdapter
Dim dt As New CustomDataSet.UserDataTable
dt.ReadXml(fsReadXML)
numFill = dta.Update(dt)

Hope this helps.
 
John,

In general, what you're seeing is normal, but the emulator will be a lot
slower than debugging on the actual device, and XML parsing is about twice
as fast in the Compact Framework v2, which is in beta until November 7. You
didn't say if your XML file includes schema, but including schema should
speed up the process a bit.

Ginny Caughey
..NET Compact Framework MVP
 
Depending on the device and your PC emulator can be slower or faster. E.g.
on my Athlon64 3500+ the xml parsing happens several times faster than on
200Mhz Symbol 2846. OTOH on a 700Mhz laptop it works 1.5. times slower than
on a 206Mhz iPaq

ReadXml will work much faster if you read the schema first. Inferring the
schema takes a lot of time
 
I found one thing that dropped the ReadXml() time for a 26kb Xml file from
over 4 minutes to about 2 seconds. In the code that I am migrating were a
number of secondary threads. They used "WaitHandle.WaitAny()" on secondary
threads to wait for any of a number of events. This is not available under
Netcf or OpenNetcf. I had constructed a "WaitForMultipleObjectsJ1()" as an
extension to the NetOpenCf code that used a WinCE Win32 call
"WaitForMultipleObjects()" to replace the missing "WaitAny()".

Unfortunately the call was always returning immediately with a failure
("invalid pointer"). This meant that the thread (which contained a while
loop) was running full out. I still don't have a replacement for the
"WaitAny()" nor do I yet understand why Win32 "WaitForMultipleObjects()" is
not accepting the handles from a ManualResetEvent object but bypassing the
"for" loop (temporarily) now the ReadXml() works much quicker.

If you have any suggestions on implementing a WaitAny() under Netcf I would
appreciate that information.

Thanks.

--
John Olbert



Ginny Caughey said:
John,

In general, what you're seeing is normal, but the emulator will be a lot
slower than debugging on the actual device, and XML parsing is about twice
as fast in the Compact Framework v2, which is in beta until November 7. You
didn't say if your XML file includes schema, but including schema should
speed up the process a bit.

Ginny Caughey
..NET Compact Framework MVP
 
John,

I think the best suggestion I can give you is to consider designing your app
so you don't need multithreading. As you have found, it's easy to get into
trouble with multithreading if you don't know what you're doing. Why do you
need the worker thread? Is there some way to accomplish what you want
without it?

Ginny

John Olbert said:
I found one thing that dropped the ReadXml() time for a 26kb Xml file from
over 4 minutes to about 2 seconds. In the code that I am migrating were a
number of secondary threads. They used "WaitHandle.WaitAny()" on secondary
threads to wait for any of a number of events. This is not available under
Netcf or OpenNetcf. I had constructed a "WaitForMultipleObjectsJ1()" as an
extension to the NetOpenCf code that used a WinCE Win32 call
"WaitForMultipleObjects()" to replace the missing "WaitAny()".

Unfortunately the call was always returning immediately with a failure
("invalid pointer"). This meant that the thread (which contained a while
loop) was running full out. I still don't have a replacement for the
"WaitAny()" nor do I yet understand why Win32 "WaitForMultipleObjects()"
is
not accepting the handles from a ManualResetEvent object but bypassing the
"for" loop (temporarily) now the ReadXml() works much quicker.

If you have any suggestions on implementing a WaitAny() under Netcf I
would
appreciate that information.

Thanks.
 
Unfortunately it is not my thread. My task is to migrate a desktop app to
Netcf (WinCe). The threads are a functional aspect of controlling a
analytical instrument (a GC Mass Spectrometer used by chemist) and cannot be
eliminated.

The real problem is the lack of the WaitAny() function in Netcf. We think we
can now handle it using a suggestion that centers around CreateEvent() in the
Wince Win32.

Thanks.
 
Back
Top