473,735 Members | 2,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

alternatives to p/invoke?

We are using SQLite.net in an application but getting a bottleneck at
the data access layer (it has been profiled). This is clearly because
p/invoke takes 5 to 10 times longer than it does calling the function
straight from C/C++ code.
Is it possible to write a wrapper in Managed C++ that provides a managed
interface to the SQLite API, but still accesses the SQLite API directly
(without using p/invoke)?

Chris
Feb 13 '06 #1
5 2783
"Chris" <ct******@yahoo .com> wrote in message
Is it possible to write a wrapper in Managed C++ that provides a managed
interface to the SQLite API, but still accesses the SQLite API directly
(without using p/invoke)?


Of course, it's also not difficult, a wizard will create the project and
class for you.

Michael
Feb 13 '06 #2

"Chris" <ct******@yahoo .com> wrote in message
news:uo******** ******@TK2MSFTN GP09.phx.gbl...
| We are using SQLite.net in an application but getting a bottleneck at
| the data access layer (it has been profiled). This is clearly because
| p/invoke takes 5 to 10 times longer than it does calling the function
| straight from C/C++ code.
| Is it possible to write a wrapper in Managed C++ that provides a managed
| interface to the SQLite API, but still accesses the SQLite API directly
| (without using p/invoke)?
|
| Chris

That won't help either, still you have to transition from managed code to
unmanaged code and back.
Did you try to apply the [SuppressUnmanag edCodeSecurity] attribute to your
PInvoke declaration?
This will reduce the overhead of a security check when transitionning.
Willy.


Feb 13 '06 #3
Willy Denoyette [MVP] wrote:
"Chris" <ct******@yahoo .com> wrote in message
news:uo******** ******@TK2MSFTN GP09.phx.gbl...
| We are using SQLite.net in an application but getting a bottleneck at
| the data access layer (it has been profiled). This is clearly because
| p/invoke takes 5 to 10 times longer than it does calling the function
| straight from C/C++ code.
| Is it possible to write a wrapper in Managed C++ that provides a managed
| interface to the SQLite API, but still accesses the SQLite API directly
| (without using p/invoke)?
|
| Chris

That won't help either, still you have to transition from managed code to
unmanaged code and back.
Did you try to apply the [SuppressUnmanag edCodeSecurity] attribute to your
PInvoke declaration?
This will reduce the overhead of a security check when transitionning.


Thats what I wanted to know.
I haven't tried using SuppressUnmanag edCodeSecurity, but I'll try that
and see kind of effect it has.

Thanks,

Chris
Feb 13 '06 #4
"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
That won't help either, still you have to transition from managed code to
unmanaged code and back.


Won't you have greater control over the process in C++ and also be able to
remove some of the checks that C# would do, hence make it faster.?

Michael
Feb 13 '06 #5

"Michael C" <no****@nospam. com> wrote in message
news:un******** ******@TK2MSFTN GP09.phx.gbl...
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| > That won't help either, still you have to transition from managed code
to
| > unmanaged code and back.
|
| Won't you have greater control over the process in C++ and also be able to
| remove some of the checks that C# would do, hence make it faster.?
|
| Michael
|
|

Not really, the process is exactly the same when you
'SuppressUnmana gedCodeSecurity ' when using PInvoke.
Whenever a thread transitions into unmanaged world the run-time has to
perform a number of housekeeping tasks, like signaling the GC that he's
leaving for a while, so that the CLR doesn't have to stop this thread when
he starts a GC sweep. Argument marshaling is another thing that must be
done, but that's the same when you are using C++ interop, the only advantage
you have with C++ interop is that you can refine the argument marshaling,
but this highly depends on the type and size of the arguments.
When a thread returns, there is the same overhead for both methods, that is,
marshaling the return and tell the GC the thread is back.
Overall, the overhead is something like 70-80 instructions when
'SuppressUnmana gedCodeSecurity ' is off (suppressed), while the overhead is
~150 instructions when it is on, this on v2 of the framework, this is
somewhat higher than it was on v1.x.

Willy.
Feb 13 '06 #6

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

Similar topics

43
5009
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own libraries. I'm not sure if that's a good thing or not. AFAIK, most of Qt is compatable with the Standard Library. That is, QLT can interoperate with STL, and you can convert back and forth between std::string and Qt::QString, etc. Are there any...
16
1817
by: RC | last post by:
I have some code that needs to know if an int variable is one of several possible values. What is a better way of performing the test than stacking a bunch of case: in a switch statement? I also don't want to have a bunch of logical ORs in an if() statement (e.g., if (someInt == 25 || someInt == 18 || someInt == 87....) Any suggestions?
1
3103
by: Spencer | last post by:
Our Mainframe DBA insists that the IDTHTOIN parameter be set to 600 so that all idle threads timeout after 10 minutes. This is causing a particular packaged application that expects to hold idle threads open for as long as it wants problems. From an application standpoint there is not an acceptable workaround that would allow the application to create connections dynamically at this point.
3
2679
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I've used an Application_BeginRequest function in my global.asax page to implement some URL rewriting functionality on our website. However, upon moving it to my host (1&1.co.uk), it no longer works. They don't support Application_BeginRequest? They've given me a list of the low-level functions they do support, which can be viewed at http://s221042302.websitehome.co.uk/check.aspx
0
8783
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
9460
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...
1
9248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6747
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
6045
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4555
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...
1
3269
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 we have to send another system
2
2737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2186
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.