473,669 Members | 2,377 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 ~StorageProvide r();

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 FileStreamStora ge();
StorageProvider *m_storage = new MemoryMappedFil e();

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 (FileStreamStor age) 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
(MemoryMappedFi le) 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; IclsDMBinaryFil e::FieldValue_G et.

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 1169

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

Similar topics

4
1301
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 can't find I thought I saw (not a puddytat). References to this other CGI speedup tool would be appreciated. But I've also been playing with performance monitoring to try and improve performance with a couple of CGI that are very very hard on...
14
2316
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 going to use .Net......I highly recommend signing up for the free KBAlertz newsletter at http://www.kbalertz.com/default.aspx. Looking at all of the errors and quirks sometimes makes me wonder if this thing is really ready for prime time.
15
1577
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 the performance in IE really bad. Have attached a simple html which simulates the prob. Any inputs on how to improve the perf in IE are greatly appreciated. Thanks, Raj
5
8792
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) - DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL But this doesn't: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
3
2599
by: Joshua Coady | last post by:
Do Trace calls have any impact on performance if Trace is disabled in the config file? Josh
10
2403
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) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
11
3475
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
5270
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 service is supposed to be installed. On some computers, notably those running Windows 2000, we get corrupted or
1
1497
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 perfect in a test c# app, but when i put it on a web app, there's a strange issue -- In perfmon, i only see one counter being affected (rest are 0)... and in my code I made a test page to just show the RawValue for each counter -- that page...
1
1493
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); ....it works ok from another web server, but on a particular one it gives this exception:
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8382
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7405
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1787
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.