473,508 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM and C++ perf problems

Hi,

background:
----------

I am the maintainer of a COM C++ dll that is used to read
binary data from a specific file format. I was recently
tasked to speed up the execution speed of this dll. In
analysis I saw that you would very often get fseek()'s
followed by either fwrite()'s or fread()'s. So my
optimisation strategy was to improve file IO by using memory
mapped file IO (using Win32).

The basic access paradigm to these files, in this
implementation, is this:

VARIANT GetData( long recordNumber, long fieldNumber );
void SetData( long recordNumber, long fieldNumber, VARIANT
data );

In other words, the file is basically a binary table storage
mechanism.

I defined the following pure virtual "interface" class that
would be the IO mechanism that the dll would use to have raw
access to the file's bytes. The idea is that I have one
implementation wrapping the stdlib's fopen(), fseek(),
fwrite/read() etc. And another class that would wrap the
memory mapped file io mechanism.

class StorageProvider
{
public:
StorageProvider();
virtual ~StorageProvider();

virtual SIZE_T FileSize() = 0;

virtual ErrorObject CreateFile( std::string FileName ) = 0;
virtual ErrorObject OpenFile( std::string FileName, bool ReadOnly ) =
0;
virtual ErrorObject CloseFile() = 0;

// if Position == -1, it means that the internal
// pointer must be used as the position.
// the internal pointer must make this behave like fread, fwrite and
fseek does
virtual ErrorObject WriteData( const void* Source, SIZE_T Length, long
Position = -1 ) = 0;
virtual ErrorObject ReadData( void* Destination, SIZE_T Length, long
Position = -1 ) = 0;
virtual ErrorObject ChangeSize( SIZE_T Size ) = 0;

virtual bool IsOpen() = 0;

protected:
ErrorObject& mError;

};

As you might see, it is meant to be used as a drop-in
replacement for the stdlib file access calls.

In the dll you have the following 2 lines that determines
whether it will use the stdlib wrapper or the memory mapped
file io wrapper:

//StorageProvider *m_storage = new FileStreamStorage();
StorageProvider *m_storage = new MemoryMappedFile();

Aside from these 2 lines, in the following problem I have
not changed one single other line at all.

I am pretty sure that the individual implementations are
correct. I used another program during development and
testing with which I wrote and read to random positions
within big files. I saw the appropriate improvement in speed
when using the memory mapped file io wrapper over the stdlib
wrapper. In the test below I also get the same data back in
both implementations.

problem:
-------
I have a VB6 appy that calls the COM dll
methods to do some test reading from a file that conforms to
the file format.

If I use the stdlib wrapper (FileStreamStorage) the
application takes a total of ~0.02 seconds on average
(determined using the GetTickCount() call in kernel32.dll).

If I use the memory mapped file io wrapper
(MemoryMappedFile) then THE SAME CODE takes ~0.8 seconds, on
average.

I have a copy of CompuWare devPartner here that says, when I
am using the memory mapped file wrapper implementation, the
time is split between code I have source for (14%) and
system (86%). In the system list the main taker-of-time is a
call to rpcrt4.dll; IclsDMBinaryFile::FieldValue_Get.

What is interesting about this is that in my dll I have
class called clsDMBinaryFile with a method
get_FieldValue(VARIANT index, VARIANT *pVal) that is
exported to COM in the IDL.

I am not clued up enough to even do further analysis. I have
very little experiance in COM so any help or pointers will
be GREATLY appreciated.

Friendly Regards,
Pieter Breed

Jul 22 '05 #1
0 1157

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1289
by: Eric S. Johansson | last post by:
I've seen a couple solutions for making CGI faster without significant rewrite. The only one I've been able to locate is fastCGI. I seem to recall something like speed CGI or speedy CGI but I...
14
2289
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
15
1553
by: Raj | last post by:
Hello all: We have a table with about 2400 cells. Our requirement is to highlight the cells in the table whose data has changed, every 5 seconds. Our script behaves relatively ok in Firefox, but...
5
8780
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
3
2593
by: Joshua Coady | last post by:
Do Trace calls have any impact on performance if Trace is disabled in the config file? Josh
10
2381
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
11
3460
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
2
5265
by: Stefan Kuhr | last post by:
Hello everyone, I hope this is not an FAQ and that somebody can answer this: As part of our webservice installation we run aspnet_regiis.exe -ir -enable on computers where the web...
1
1491
by: Ben | last post by:
Hi, I registered some custom perf counters that i want to use in my app (all of type NumberOfItems32). I added them under the same category name but different counter names... Same code work...
1
1479
by: Ben | last post by:
hi, i have this line in a web app to create a custom perf category: PerformanceCounterCategory.Create(categoryName, categoryDesc, PerformanceCounterCategoryType.SingleInstance, ccdc); ...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.