473,406 Members | 2,404 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,406 software developers and data experts.

.NET Compiler optimization and component updates

All,

This is a general question regarding how, and if, compiler optimization
techniques affect the general concept of being able to update a component of
an application without requiring a recompile of client code.

For example, suppose I have component: common.dll which defines several
constant values, say Const_A, Const_B and Const_C. Further say I have some
client code in another component: client.dll which references common.dll and
the constants defined within it. If I redefine the values of the constant
values and redeploy common.dll, will client.dll use the new values?

I encountered a situation like this in which client.dll did not use the
redefined constant values until I recompiled client.dll against the newer
version of common.dll.

I expect the compiler inlines the constant values for optimization, but does
this in someway break the concept of being able to modify and redeploy server
components without having to recompile client code? Also, what happens when
the compiler uses other optimization techniques like function inlining?

I guess my real question is when do I know it's safe to just redeploy
client.dll without needing to recompile client.dll?

I'm certainly not an expert in compiler construction or optimization so any
insight is appreciated.

Thanks,
Nick
Jul 21 '05 #1
3 3284
Nick L. <Ni***@discussions.microsoft.com> wrote:
This is a general question regarding how, and if, compiler optimization
techniques affect the general concept of being able to update a component of
an application without requiring a recompile of client code.

For example, suppose I have component: common.dll which defines several
constant values, say Const_A, Const_B and Const_C. Further say I have some
client code in another component: client.dll which references common.dll and
the constants defined within it. If I redefine the values of the constant
values and redeploy common.dll, will client.dll use the new values?
If they're truly constants, declared as constants rather than static
readonly values, then it'll use the old values.
I encountered a situation like this in which client.dll did not use the
redefined constant values until I recompiled client.dll against the newer
version of common.dll.
Yup.
I expect the compiler inlines the constant values for optimization, but does
this in someway break the concept of being able to modify and redeploy server
components without having to recompile client code? Also, what happens when
the compiler uses other optimization techniques like function inlining?
Inlining is done by the JIT compiler, not the language -> IL compiler.
I guess my real question is when do I know it's safe to just redeploy
client.dll without needing to recompile client.dll?


Even in times when it's *safe* to redeploy just the library without
redeploying things compiled against it, I believe it would be *better*
to recompile everything. From what I remember about the file format,
there are "hints" in the file to say where methods in other assemblies
are likely to be, etc. It should work if they've changed location, but
slightly slower.

You should always recompile to check that the interfaces etc haven't
changed in an incompatible way, of course, but the choice of whether or
not to then redeploy is a tricky one. The interfaces may have changed
in a source-compatible but not binary-compatible way (eg you may have
changed a method from Foo(string s) to Foo(object o), and everything
will still recompile, but old programs will fail to link at runtime).
Then there's the constants problem you brought up.

I think things are slightly worse in the compact framework - I believe
there's a stronger tie there, and you *have* to recompile the
assemblies which depend on the changed assembly. (I've certainly seen
things fail for no good reason if that's not the case.)

As you can tell, I'm pretty conservative about this kind of thing,
myself...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Thanks Jon, I appreciate your feedback; it has been very helpful.

"Jon Skeet [C# MVP]" wrote:
Nick L. <Ni***@discussions.microsoft.com> wrote:
This is a general question regarding how, and if, compiler optimization
techniques affect the general concept of being able to update a component of
an application without requiring a recompile of client code.

For example, suppose I have component: common.dll which defines several
constant values, say Const_A, Const_B and Const_C. Further say I have some
client code in another component: client.dll which references common.dll and
the constants defined within it. If I redefine the values of the constant
values and redeploy common.dll, will client.dll use the new values?


If they're truly constants, declared as constants rather than static
readonly values, then it'll use the old values.
I encountered a situation like this in which client.dll did not use the
redefined constant values until I recompiled client.dll against the newer
version of common.dll.


Yup.
I expect the compiler inlines the constant values for optimization, but does
this in someway break the concept of being able to modify and redeploy server
components without having to recompile client code? Also, what happens when
the compiler uses other optimization techniques like function inlining?


Inlining is done by the JIT compiler, not the language -> IL compiler.
I guess my real question is when do I know it's safe to just redeploy
client.dll without needing to recompile client.dll?


Even in times when it's *safe* to redeploy just the library without
redeploying things compiled against it, I believe it would be *better*
to recompile everything. From what I remember about the file format,
there are "hints" in the file to say where methods in other assemblies
are likely to be, etc. It should work if they've changed location, but
slightly slower.

You should always recompile to check that the interfaces etc haven't
changed in an incompatible way, of course, but the choice of whether or
not to then redeploy is a tricky one. The interfaces may have changed
in a source-compatible but not binary-compatible way (eg you may have
changed a method from Foo(string s) to Foo(object o), and everything
will still recompile, but old programs will fail to link at runtime).
Then there's the constants problem you brought up.

I think things are slightly worse in the compact framework - I believe
there's a stronger tie there, and you *have* to recompile the
assemblies which depend on the changed assembly. (I've certainly seen
things fail for no good reason if that's not the case.)

As you can tell, I'm pretty conservative about this kind of thing,
myself...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3
"Nick L." <Ni***@discussions.microsoft.com> wrote in
news:53**********************************@microsof t.com...
All,

This is a general question regarding how, and if, compiler optimization
techniques affect the general concept of being able to update a component
of
an application without requiring a recompile of client code.

For example, suppose I have component: common.dll which defines several
constant values, say Const_A, Const_B and Const_C. Further say I have some
client code in another component: client.dll which references common.dll
and
the constants defined within it. If I redefine the values of the constant
values and redeploy common.dll, will client.dll use the new values?
Keep in mind that C# code will be compiled to IL code at compile time (by
the C# compiler), and IL will be compiled to native code at runtime (by the
JIT):
Now, there is no representation for constants in IL code - the C# compiler
already translates them to their values.
I encountered a situation like this in which client.dll did not use the
redefined constant values until I recompiled client.dll against the newer
version of common.dll.

I expect the compiler inlines the constant values for optimization, but
does
this in someway break the concept of being able to modify and redeploy
server
components without having to recompile client code? Also, what happens
when
the compiler uses other optimization techniques like function inlining?
Function inlining is done by the JIT, so this won't break anything.
I guess my real question is when do I know it's safe to just redeploy
client.dll without needing to recompile client.dll?


This is more a rule of thumb: You can usually safely change private members
(unless you use binary serialization), change code (see below), and add new
members. AFAIK this is more or less the strategy MS uses for updates and
service packs.

Note that "you don't have to recompile" doesn't mean "you don't have to
re-test": Changing a method can *always* break client code if you change
pre- or postconditions, throw new exceptions or whatever. But doing this can
break client code if you recompile it, too.

Niki
Jul 21 '05 #4

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

Similar topics

7
by: Stephan Diehl | last post by:
A while ago, I've posted a recipie about finding a common prefix to a list of strings. While the recipie itself is quite bad (I have to admit) and I didn't know at that time that this problem was...
14
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
5
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and...
3
by: gabe | last post by:
I have a general design question. What's a 'Best Practice' for middle tier component design? I'm thinking of a web form that contains data from multiple tables. The data is supplied from one...
3
by: Nick L. | last post by:
All, This is a general question regarding how, and if, compiler optimization techniques affect the general concept of being able to update a component of an application without requiring a...
44
by: Don Kim | last post by:
Ok, so I posted a rant earlier about the lack of marketing for C++/CLI, and it forked over into another rant about which was the faster compiler. Some said C# was just as fast as C++/CLI, whereas...
5
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
30
by: lovecreatesbea... | last post by:
K&R says the following in the preface to the first edition, "... the C compiler, and ... are written in C." I'm wondering, does it say even the first / original C compiler was written in C?
29
by: sammy | last post by:
Word up! If there are any gcc users here, maybe you could help me out. I have a program and I've tried compiling it with -O2 and -O3 optimization settings. The wired thing is that it actually...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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
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...

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.