473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Way to improve managed code performance

Hi,

I hope this post will find it's way to some MS technical authority...

I am experienced with bought Unmanaged C++ and Managed code ( C# ), There
are some issues with the .NET framework that make me wonder...

Take in mind the following points:
1. Managed objects are managed by the GC through the managed heap.
2. The GC moves the physical data representation of managed objects to
reserve address space.

Problems with this logic:
******************
A. to be able to access the physical address space directly ( through
unmanaged code ) one would have to 'pin' the managed object, hence,
preventing the GC from moving the physical data around, pinning data in such
a way causes a performance degradation.
B. Passing unmanaged pointers to methods with managed Object type variables
is not possible, a managed wrapper must be created and the data should be
copied to the managed buffer, doing rapid memory coping dramatically reduce
performance...

Resolution:
********
64bit computing offers a huge address space, this makes the need for the GC
memory compacting mechanism unnecessary as the address-space is so large,
disabling memory compaction will cancel the need of pinning managed objects (
as they will be pinned anyhow ) and will enable more efficient data transfer
between managed and unmanaged code ( as referred to in B. )

Nadav
nadavrub AT gmail DOT com
Nov 16 '05 #1
4 1966
have you ever used a computer where the hard drive is fragmented over 95% ?
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi,

I hope this post will find it's way to some MS technical authority...

I am experienced with bought Unmanaged C++ and Managed code ( C# ), There
are some issues with the .NET framework that make me wonder...

Take in mind the following points:
1. Managed objects are managed by the GC through the managed heap.
2. The GC moves the physical data representation of managed objects to
reserve address space.

Problems with this logic:
******************
A. to be able to access the physical address space directly ( through
unmanaged code ) one would have to 'pin' the managed object, hence,
preventing the GC from moving the physical data around, pinning data in such a way causes a performance degradation.
B. Passing unmanaged pointers to methods with managed Object type variables is not possible, a managed wrapper must be created and the data should be
copied to the managed buffer, doing rapid memory coping dramatically reduce performance...

Resolution:
********
64bit computing offers a huge address space, this makes the need for the GC memory compacting mechanism unnecessary as the address-space is so large,
disabling memory compaction will cancel the need of pinning managed objects ( as they will be pinned anyhow ) and will enable more efficient data transfer between managed and unmanaged code ( as referred to in B. )

Nadav
nadavrub AT gmail DOT com

Nov 16 '05 #2
Logical disconnect: "64bit computing offers a huge address space"

"Address space" does not equal "available RAM". Just because my machine
can address so many trillions of bytes does not mean that I have that
installed on my motherboard.

Writing a system that assumes that I have massive amounts of memory
available when, in fact, I don't results in two potential problems:

1. An application that gobbles massive amounts of memory when it
doesn't have to. Perhaps more than I have, leading it to run like a
pig. And, even if I really do have that much memory...

2. An application that gobbles up more memory than it needs to, and so
leaves less memory for other applications running in the same
(physical) memory that could probably use that memory in order to do
something useful.

It's bad enough that you can now suck up a meg of RAM without meaning
to on a single (ill-conceived) method call in O-O languages, without
the garbage collector getting into the act and not bothering to make
efficient use of memory because there's "lots there".

If you're so concerned about low-level efficiencies in your code,
_don't use a garbage-collected language like C#_. Don't try to hammer
in a screw. Don't push on a rope. If you want raw speed, or you need
predictable real-time deadlines, use C or C++ compiled to unmanaged
code. Yes, the garbage collector often gets in the way of performance;
for that reason, if you need that much performance, don't use a GCed
language.

Nov 16 '05 #3
_R
On 17 Feb 2005 09:40:58 -0800, "Bruce Wood" <br*******@canada.com>
wrote:
If you're so concerned about low-level efficiencies in your code,
_don't use a garbage-collected language like C#_. Don't try to hammer
in a screw. Don't push on a rope. If you want raw speed, or you need
predictable real-time deadlines, use C or C++ compiled to unmanaged
code. Yes, the garbage collector often gets in the way of performance;
for that reason, if you need that much performance, don't use a GCed
language.


I realize I'm a couple weeks late replying to this, but why would C#
be inherently so much weaker at memory allocation in comparison
to C++? I understand the possible performance issues, but it sounded
like you were saying that the alloc mechanism itself is inferior.

Or were you referring to the fact that not explicitly dealllocing ram
at chosen times causes the problems?

Nov 16 '05 #4
My impression is that GC'ed memory allocation is blindingly fast, and stays
this way until you run out of memory and have to GC. So, if you have 1 GB
of RAM and need 128 KB, you will never see a slowdown from GC. If you have
1 GB of RAM and need 128 MB over and over, then this will be an issue.

If you know exactly what you will be doing with memory, the fastest scheme
is probably to do it yourself. I write some code where I needed to flip
back and forth between two tables, and there was no reason to ask the memory
system to help me ... I just allocate two tables, and flip back and forth
between them. If your memory needs are random and unpredictable, then GC is
your friend ... just let it do its thing

Just my 2c.

Tad

"_R" <_R@nomail.org> wrote in message
news:n7********************************@4ax.com...
On 17 Feb 2005 09:40:58 -0800, "Bruce Wood" <br*******@canada.com>
wrote:
If you're so concerned about low-level efficiencies in your code,
_don't use a garbage-collected language like C#_. Don't try to hammer
in a screw. Don't push on a rope. If you want raw speed, or you need
predictable real-time deadlines, use C or C++ compiled to unmanaged
code. Yes, the garbage collector often gets in the way of performance;
for that reason, if you need that much performance, don't use a GCed
language.


I realize I'm a couple weeks late replying to this, but why would C#
be inherently so much weaker at memory allocation in comparison
to C++? I understand the possible performance issues, but it sounded
like you were saying that the alloc mechanism itself is inferior.

Or were you referring to the fact that not explicitly dealllocing ram
at chosen times causes the problems?

Nov 17 '05 #5

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

Similar topics

22
by: Alper AKCAYOZ | last post by:
Hello Esteemed Developers and Experts, I have been using Microsoft Visual C++ .NET for 1 year. During this time, I have searhed some topics over internets. Most of the topics about .NET is...
9
by: Peng Jian | last post by:
I have a function that is called very very often. Can I improve its efficiency by declaring its local variables to be static?
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
6
by: Jéjé | last post by:
Hi, hoew can I improve the compilation process of a sharepoint website? my server is: 2 * P3 Xeom 1ghz 4go ram 2 * 36gb (mirror for OS and website) 2 * 36 Raid 0 (stripping; for temp files...
87
by: Robert Seacord | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for...
5
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I have a class that is writen in unmanaged pure native C++. This class files (h and cpp) are inserted to a managed C++ (VC++ 2005, C++/CLI) DLL compoenet. This DLL compoenet is used in a C#...
2
by: sdanda | last post by:
Hi , Do you have any idea how to improve my java class performance while selecting and inserting data into DB using JDBC Connectivity ......... This has to work for more than 8,00,000...
66
by: John | last post by:
Hi What are the advantages actually achieved of managed code? I am not talking of theory but in reality. Thanks Regards
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...

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.