- Getting started
- Understanding the JQuery function
- Chaining
- Getting started with selectors
- More on selectors
- Custom selectors
- Understanding how selectors are implemented
- Working with the wrapped HTML elements – part I
- Working with the wrapped HTML elements – part II
- Working with the wrapped set – part III
Software Development : A dizzy job...keeping abreast and being competitive is a 24X7 involvement
Jan 15, 2013
A nice and informative JQuery tutorial
Learning resources for Entity Framework 4.0 new features
(http://bogdanbrinzarea.wordpress.com/2009/08/05/learning-resources-for-entity-framework-4-0-new-features/)
http://blogs.msdn.com/adonet/archive/2009/06/22/announcing-entity-framework-feature-ctp-1.aspx
http://blog.tonysneed.com/?p=161
http://www.develop.com/entityframework4
http://thedatafarm.com/blog/data-access/important-entity-framework-query-improvements-for-net-4-0/
http://blogs.msdn.com/adonet/archive/2009/05/11/sneak-preview-persistence-ignorance-and-poco-in-entity-framework-4-0.aspx
http://blogs.msdn.com/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://blogs.msdn.com/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://blogs.msdn.com/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx
http://mosesofegypt.net/post/Entity-Framework-4-Persistence-Ignorance-First-Look.aspx
http://blogs.msdn.com/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://thedatafarm.com/blog/data-access/a-look-at-lazy-loading-in-ef4/
http://www.simonsegal.net/blog/2009/07/27/entity-framework-40-improvements/
http://www.simonsegal.net/blog/2009/07/29/entity-framework-40-and-fetching-strategies/
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/23/calling-database-functions-in-linq-to-entities-in-entity-framework-4.aspx
Tip 30 – How to use a custom database function
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/23/calling-database-functions-in-linq-to-entities-in-entity-framework-4.aspx
http://thedatafarm.com/blog/data-access/ef4-model-defined-functions-level-1-amp-2/
http://blogs.msdn.com/adonet/archive/2009/05/12/sneak-preview-model-first-in-the-entity-framework-4-0.aspx
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/23/model-first-in-entity-framework-4.aspx
http://channel9.msdn.com/shows/10-4/10-4-Episode-15-Model-First-Development-with-the-Entity-Framework-40/
http://thedatafarm.com/blog/data-access/ef4-ndash-new-properties-for-entity-properties/
http://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-code-only-for-entity-framework.aspx
http://blogs.msdn.com/efdesign/archive/2009/08/03/code-only-enhancements.aspx
http://blogs.msdn.com/alexj/archive/2009/08/12/tip-32-how-to-create-a-database-from-ssdl-ef-4-only.aspx
http://blogs.msdn.com/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://thedatafarm.com/blog/data-access/a-big-step-for-stored-procedures-in-ef4/
http://thedatafarm.com/blog/data-access/complex-types-in-the-edm-designer-in-ef4-and-a-look-at-updating-complex-types-in-code/
http://blog.keithpatton.com/2009/05/30/Entity+Framework+POCO+Repository+Using+Visual+Studio+2010+Net+40+Beta+1.aspx
http://blogs.msdn.com/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx
http://thedatafarm.com/blog/data-access/another-clever-pattern-for-dealingi-wtih-ef-change-tracking-across-processes/
http://msdn.microsoft.com/en-us/magazine/ee321569.aspx
http://msdn.microsoft.com/en-us/magazine/ee321569.aspx
http://blogs.msdn.com/efdesign/archive/2009/03/24/self-tracking-entities-in-the-entity-framework.aspx
http://blogs.msdn.com/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx
http://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-self-tracking-entities-for-entity-framework.aspx
http://weblogs.asp.net/gunnarpeipman/archive/2009/07/11/entity-framework-4-0-how-to-use-pocos.aspx
http://thedatafarm.com/blog/data-access/ef-why-work-with-objectstateentries-instead-of-the-objects-directly/
http://thedatafarm.com/blog/data-access/customizing-edm-code-gen-in-ef4/
http://thedatafarm.com/blog/data-access/small-ef4-wpf-bug-that-bit-me-in-the-butt-during-my-vtdotnet-presentation/
http://blogs.msdn.com/adonet/archive/2009/05/19/sneak-peek-using-code-generation-templates-with-the-entity-framework-4-0.aspx
http://blogs.msdn.com/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-poco-templates-for-entity-framework.aspx
http://msmvps.com/blogs/matthieu/archive/2009/06/26/poco-t4.aspx
http://blogs.msdn.com/adonet/archive/2009/07/22/customizing-t4-templates.aspx
http://blogs.msdn.com/adonet/archive/2009/05/20/sneak-preview-pluralization-in-entity-framework-4-0.aspx
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/22/pluralize-or-singularize-generated-object-names-checkbox-in-entity-framework-4.aspx
Tip 31 – How to compose L2O and L2E queries
Tip 30 – How to use a custom database function
Tip 29 – How to avoid LazyLoad or Load() reader issues
Tip 28 – How to implement an Eager Loading strategy
Tip 27 – How to Implement BeforeSave Validation
Tip 26 – How to avoid database queries using Stub Entities
Tip 25 – How to get Entities by key the easy way
Tip 24 – How to get the ObjectContext from an Entity
Tip 23 – How to fake Enums in EF 4
Tip 22 – How to make Include really Include
Tip 21 – How to use the Single() operator – EF 4.0 only
Tip 20 – How to deal with Fixed Length Keys
Tip 19 – How to use Optimistic Concurrency with the Entity Framework
Tip 18 – How to decide on a lifetime for your ObjectContext
Tip 17 – How to do one step updates with AttachAsModified(..)
Tip 16 – How to mimic .NET 4.0’s ObjectSet today
Tip 15 – How to avoid loading unnecessary Properties
Tip 14 – How to cache Entity Framework Reference Data
Tip 13 – How to Attach an Entity the easy way
Tip 12 – How to choose an Inheritance Strategy
Tip 11 – How to avoid Relationship Span
Tip 10 – How to understand Entity Framework jargon
Tip 9 – How to delete an object without retrieving it
Tip 8 – How to write ‘WHERE IN’ style queries using LINQ to Entities
Tip 7 – How to fake Foreign Key Properties in .NET 3.5 SP1
Tip 6 – How and when to use eager loading
Tip 5 – How to restrict the types returned from an EF Query
Tip 4 – Conceptual Schema Definition Language Rules
Tip 3 – How to get started with T4
Tip 2 – Entity Framework Books
Tip 1 – How to sort Relationships in the Entity Framework
New features
http://blogs.msdn.com/adonet/archive/2009/05/21/updated-entity-framework-documentation-for-beta1.aspxhttp://blogs.msdn.com/adonet/archive/2009/06/22/announcing-entity-framework-feature-ctp-1.aspx
http://blog.tonysneed.com/?p=161
http://www.develop.com/entityframework4
SQL improvements
http://blogs.msdn.com/adonet/archive/2009/08/05/improvements-to-the-generated-sql-in-net-4-0-beta1.aspxhttp://thedatafarm.com/blog/data-access/important-entity-framework-query-improvements-for-net-4-0/
POCO Objects
http://msdn.microsoft.com/en-us/magazine/ee236639.aspxhttp://blogs.msdn.com/adonet/archive/2009/05/11/sneak-preview-persistence-ignorance-and-poco-in-entity-framework-4-0.aspx
http://blogs.msdn.com/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://blogs.msdn.com/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://blogs.msdn.com/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx
http://mosesofegypt.net/post/Entity-Framework-4-Persistence-Ignorance-First-Look.aspx
Deferred Loading and Explicit Loading
http://blogs.msdn.com/adonet/archive/2009/05/12/sneak-preview-deferred-loading-in-entity-framework-4-0.aspxhttp://blogs.msdn.com/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://thedatafarm.com/blog/data-access/a-look-at-lazy-loading-in-ef4/
http://www.simonsegal.net/blog/2009/07/27/entity-framework-40-improvements/
http://www.simonsegal.net/blog/2009/07/29/entity-framework-40-and-fetching-strategies/
Functions in LINQ to Entities
http://thedatafarm.com/blog/data-access/checking-out-one-of-the-new-stored-procedure-features-in-ef4/http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/23/calling-database-functions-in-linq-to-entities-in-entity-framework-4.aspx
Tip 30 – How to use a custom database function
Model Defined Functions
http://blogs.msdn.com/adonet/archive/2009/05/14/sneak-preview-model-defined-functions.aspxhttp://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/23/calling-database-functions-in-linq-to-entities-in-entity-framework-4.aspx
http://thedatafarm.com/blog/data-access/ef4-model-defined-functions-level-1-amp-2/
EDM Designer
http://msdn.microsoft.com/en-us/library/dd456821(VS.100).aspxModel-First Support
http://msdn.microsoft.com/en-us/magazine/ee236639.aspxhttp://blogs.msdn.com/adonet/archive/2009/05/12/sneak-preview-model-first-in-the-entity-framework-4-0.aspx
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/23/model-first-in-entity-framework-4.aspx
http://channel9.msdn.com/shows/10-4/10-4-Episode-15-Model-First-Development-with-the-Entity-Framework-40/
http://thedatafarm.com/blog/data-access/ef4-ndash-new-properties-for-entity-properties/
Code Only Support
http://blogs.msdn.com/efdesign/archive/2009/06/10/code-only.aspxhttp://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-code-only-for-entity-framework.aspx
http://blogs.msdn.com/efdesign/archive/2009/08/03/code-only-enhancements.aspx
http://blogs.msdn.com/alexj/archive/2009/08/12/tip-32-how-to-create-a-database-from-ssdl-ef-4-only.aspx
Complex Type Support
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/22/complex-type-support-in-the-edm-designer-in-entity-framework-4.aspxhttp://blogs.msdn.com/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx
http://thedatafarm.com/blog/data-access/a-big-step-for-stored-procedures-in-ef4/
http://thedatafarm.com/blog/data-access/complex-types-in-the-edm-designer-in-ef4-and-a-look-at-updating-complex-types-in-code/
Table splitting
http://thedatafarm.com/blog/data-access/ef-table-splitting-ndash-the-opposite-of-entity-splitting/Testability
http://blogs.msdn.com/adonet/archive/2009/05/18/sneak-preview-entity-framework-4-0-testability-improvements.aspxDesign patterns
http://msdn.microsoft.com/en-us/magazine/ee236639.aspxhttp://blog.keithpatton.com/2009/05/30/Entity+Framework+POCO+Repository+Using+Visual+Studio+2010+Net+40+Beta+1.aspx
http://blogs.msdn.com/adonet/archive/2009/06/16/using-repository-and-unit-of-work-patterns-with-entity-framework-4-0.aspx
http://thedatafarm.com/blog/data-access/another-clever-pattern-for-dealingi-wtih-ef-change-tracking-across-processes/
Events
http://romiller.com/Home/tabid/36/EntryID/51/Default.aspxArchitecture
http://blogs.msdn.com/adonet/archive/2009/05/14/sneak-preview-n-tier-development-with-entity-framework-4-0.aspxhttp://msdn.microsoft.com/en-us/magazine/ee321569.aspx
Self tracking entities
http://blogs.msdn.com/adonet/archive/2009/05/14/sneak-preview-n-tier-development-with-entity-framework-4-0.aspxhttp://msdn.microsoft.com/en-us/magazine/ee321569.aspx
http://blogs.msdn.com/efdesign/archive/2009/03/24/self-tracking-entities-in-the-entity-framework.aspx
http://blogs.msdn.com/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx
http://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-self-tracking-entities-for-entity-framework.aspx
http://weblogs.asp.net/gunnarpeipman/archive/2009/07/11/entity-framework-4-0-how-to-use-pocos.aspx
POCO T4 templates
http://msdn.microsoft.com/en-us/magazine/ee236639.aspxhttp://thedatafarm.com/blog/data-access/ef-why-work-with-objectstateentries-instead-of-the-objects-directly/
http://thedatafarm.com/blog/data-access/customizing-edm-code-gen-in-ef4/
http://thedatafarm.com/blog/data-access/small-ef4-wpf-bug-that-bit-me-in-the-butt-during-my-vtdotnet-presentation/
http://blogs.msdn.com/adonet/archive/2009/05/19/sneak-peek-using-code-generation-templates-with-the-entity-framework-4-0.aspx
http://blogs.msdn.com/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-poco-templates-for-entity-framework.aspx
http://msmvps.com/blogs/matthieu/archive/2009/06/26/poco-t4.aspx
http://blogs.msdn.com/adonet/archive/2009/07/22/customizing-t4-templates.aspx
Validation
http://blogs.msdn.com/alexj/archive/2009/07/20/tip-27-how-to-implement-beforesave-validation.aspxEDM designer
http://thedatafarm.com/blog/data-access/more-designer-improvements-deleting-entities-from-the-model-and-from-the-store-schema/Foreign keys
http://blogs.msdn.com/efdesign/archive/2009/03/16/foreign-keys-in-the-entity-framework.aspxPluralization
http://blogs.msdn.com/efdesign/archive/2008/12/02/pluralization.aspxhttp://blogs.msdn.com/adonet/archive/2009/05/20/sneak-preview-pluralization-in-entity-framework-4-0.aspx
http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/22/pluralize-or-singularize-generated-object-names-checkbox-in-entity-framework-4.aspx
Tips
Tip 32 – How to create a database from SSDL – EF 4 onlyTip 31 – How to compose L2O and L2E queries
Tip 30 – How to use a custom database function
Tip 29 – How to avoid LazyLoad or Load() reader issues
Tip 28 – How to implement an Eager Loading strategy
Tip 27 – How to Implement BeforeSave Validation
Tip 26 – How to avoid database queries using Stub Entities
Tip 25 – How to get Entities by key the easy way
Tip 24 – How to get the ObjectContext from an Entity
Tip 23 – How to fake Enums in EF 4
Tip 22 – How to make Include really Include
Tip 21 – How to use the Single() operator – EF 4.0 only
Tip 20 – How to deal with Fixed Length Keys
Tip 19 – How to use Optimistic Concurrency with the Entity Framework
Tip 18 – How to decide on a lifetime for your ObjectContext
Tip 17 – How to do one step updates with AttachAsModified(..)
Tip 16 – How to mimic .NET 4.0’s ObjectSet
Tip 15 – How to avoid loading unnecessary Properties
Tip 14 – How to cache Entity Framework Reference Data
Tip 13 – How to Attach an Entity the easy way
Tip 12 – How to choose an Inheritance Strategy
Tip 11 – How to avoid Relationship Span
Tip 10 – How to understand Entity Framework jargon
Tip 9 – How to delete an object without retrieving it
Tip 8 – How to write ‘WHERE IN’ style queries using LINQ to Entities
Tip 7 – How to fake Foreign Key Properties in .NET 3.5 SP1
Tip 6 – How and when to use eager loading
Tip 5 – How to restrict the types returned from an EF Query
Tip 4 – Conceptual Schema Definition Language Rules
Tip 3 – How to get started with T4
Tip 2 – Entity Framework Books
Tip 1 – How to sort Relationships in the Entity Framework
Learning resources for ASP.NET 4.0 WebForms new features
(http://bogdanbrinzarea.wordpress.com/2009/08/06/learning-resources-for-asp-net-4-0-webforms-new-features/)
General
http://videos.visitmix.com/MIX09/T46Fhttp://channel9.msdn.com/shows/The+Knowledge+Chamber/Stephen-Walther-New-Features-of-ASPNET-40/
http://blogs.msdn.com/publicsector/archive/2009/03/25/devdinnerondemand-what-s-new-in-asp-net-4-0.aspx
http://blogs.msdn.com/scothu/archive/2009/03/23/asp-net-4-0-and-visual-studio-2010-development-overview-dynamic-data.aspx
http://www.asp.net/learn/whitepapers/aspnet40/
http://haacked.com/archive/2008/11/13/future-of-aspnet.aspx
WebForms
http://blogs.msdn.com/mikeormond/archive/2009/05/06/asp-net-4-0-webforms-enhancements.aspxhttp://channel9.msdn.com/shows/10-4/10-4-Episode-3-ASPNET-WebForms-40/
http://mostlylucid.net/archive/2009/01/01/asp.net-4.0-webforms-podcast-is-now-up.aspx
http://blogs.msdn.com/mikeormond/archive/2009/04/16/visual-studio-2010-enhancements-for-asp-net.aspx
http://mostlylucid.net/archive/2009/01/29/1313.aspx
Client ID
http://mostlylucid.net/archive/2008/11/03/way-too-much-information-on-control-ids-and-asp.net-4.0.aspxhttp://blog.osbornm.com/archive/2009/01/06/asp.net-4.0-clientid-overview-again.aspx
ViewState
http://weblogs.asp.net/despos/archive/2009/06/13/asp-net-4-0-more-control-on-viewstate-management.aspxhttp://mostlylucid.net/archive/2009/01/28/1312.aspx
Data Controls
http://blogs.msdn.com/mikeormond/archive/2009/06/29/asp-net-4-0-enhancements-to-data-controls.aspxhttp://csharpbits.notaclue.net/2009/03/cascading-or-dependant-field-templates.html
Routing
http://mostlylucid.net/archive/2009/05/19/1322.aspxhttp://mostlylucid.net/archive/2009/01/25/asp.net-4.0-webform-routing-quick-rsquon-dirty-version.aspx
http://haacked.com/archive/2009/01/25/routing-for-web-forms-in-asp.net-4.0.aspx
Dynamic Images
http://www.hanselman.com/blog/ASPNETFuturesGeneratingDynamicImagesWithHttpHandlersGetsEasier.aspxhttp://blogs.msdn.com/scothu/archive/2008/08/21/image-generation-is-released-to-codeplex.aspx
http://davidhayden.com/blog/dave/archive/2008/08/27/ASPNETImageGenerationGenerateImagesGetImagesDatabaseTransformImages.aspx
http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449
Control Adapters
http://mostlylucid.net/archive/2009/04/27/1319.aspxTesting
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28536Ways to improve garbage collection performance for windows apps
Improve garbage collection performance (Windows Store apps using C#/VB) (Windows)
(http://msdn.microsoft.com/en-us/library/windows/apps/hh994643.aspx)
Windows Store apps written in C# and Visual Basic get automatic
memory management from the .NET garbage collector. This section
summarizes the behavior and performance best practices for the .NET
garbage collector in Windows Store apps. For more info on how the .NET
garbage collector works and tools for debugging and analyzing garbage
collector performance, see Garbage collection.
The garbage collector determines when to run by balancing the memory
consumption of the managed heap with the amount of work a garbage
collection needs to do. One of the ways the garbage collector does this
is by dividing the heap into generations and collecting only part of the
heap most of the time. There are three generations in the managed heap:
- Generation 0. This generation contains newly allocated objects unless they are 85,000 bytes or larger, in which case they are part of the large object heap. The large object heap is collected with generation 2 collections. Generation 0 collections are the most frequently occurring type of collection and clean up short-lived objects such as local variables.
- Generation 1. This generation contains objects that have survived generation 0 collections. It serves as a buffer between generation 0 and generation 2. Generation 1 collections occur less frequently than generation 0 collections and clean up temporary objects that were active during previous generation 0 collections. A generation 1 collection also collects generation 0.
- Generation 2. This generation contains long-lived objects that have survived generation 0 and generation 1 collections. Generation 2 collections are the least frequent and collect the entire managed heap, including the large object heap which contains objects that are 85,000 bytes or larger.
You can measure the performance of the garbage collector in 2
aspects: the amount of time it takes to do the garbage collection and
the memory consumption of the managed heap. As mentioned earlier, the
garbage collector strives for the best balance between the two. If you
have a small app with a heap size that’s less than 100MB, focus on
reducing memory consumption. If you have an app with a managed heap
that’s larger than 100M, focus on reducing the garbage collection time
only. You can help the .NET garbage collector achieve better performance
by following the tips we look at next.
Reduce memory consumption
Remove references
A reference to an object in your app prevents that object, and all of
the objects it references, from being collected. The .NET just-in-time
(JIT) compiler does a good job of detecting when a variable is no longer
in use so objects held onto by that variable will be eligible for
collection. But in some cases it may not be obvious that some objects
have a reference to other objects because part of the object graph might
be owned by libraries your app uses. To learn about the tools and
techniques to find out which objects survive a garbage collection, see Garbage collection and performance.
Induce a garbage collection if it’s useful
Induce a garbage collection only after you have measured your app's
performance and have determined that inducing a collection will improve
its performance.
You can induce a garbage collection of a generation by calling GC.Collect(n),
where n is the generation you want to collect (0, 1, or 2). We
recommend that you don't force a garbage collection in your app because
the garbage collector uses many heuristics to determine the best time
to perform a collection, and forcing a collection is in many cases an
unnecessary use of the CPU. But if you know that you have a large number
of objects in your app that are suddenly no longer used and you want
to return this memory to the system, then it may be appropriate to force
a garbage collection. For example, you can induce a collection at the
end of a loading sequence in a game to free up memory before gameplay
starts.
To avoid accidently inducing too many garbage collections, you can set the GCCollectionMode to Optimized.
This instructs the garbage collector to start a collection only if it
determines that the collection would be productive enough to be
justified.
Reduce garbage collection time
Follow the best practices here only after you've analyzed your app
and observed large garbage collection times that you want to reduce.
There are 2 aspects of garbage collection-related pause times: the time
it takes to run a single garbage collection pass, and the total time
your app spends doing garbage collections. The amount of time it takes
to do a collection depends on how much live data the collector has to
analyze. Generation 0 and generation 1 are bounded in size, but
generation 2 continues to grow as more long-lived objects are active in
your app. This means that the collection times for generation 0 and
generation 1 are bounded, while generation 2 collections have the
potential of taking a longer amount of time. How often garbage
collections run depends mostly on how much memory you allocate, because a
garbage collection frees up memory to satisfy allocation requests.
The garbage collector occasionally pauses your app to perform work,
but doesn't necessarily pause your app the entire time it is doing a
collection. Pause times are usually not user-perceivable in your app,
especially for generation 0 and generation 1 collections. The Background garbage collection
feature of the .NET garbage collector allows Generation 2 collections
to be performed concurrently while your app is running and will only
pause your app for short periods of time. But it is not always possible
to do a Generation 2 collection as a background collection. In that
case, the pause can be user-perceivable if you have a large enough heap
(more than 100MB).
Frequent garbage collections can contribute to increased CPU (and
therefore power) consumption, longer loading times, or decreased frame
rates in your application. Below are some techniques you can use to
reduce garbage collection time and collection-related pauses in your
managed Windows Store app.
Reduce memory allocations
If you don’t allocate any objects then the garbage collector doesn’t
run unless there is a low memory condition in the system. Reducing the
amount of memory you allocate directly translates to less frequent
garbage collections.
If in some sections of your app pauses are completely undesirable,
then you can pre-allocate the necessary objects beforehand during a less
performance-critical time. For example, a game might allocate all of
the objects needed for gameplay during the loading screen of a level and
not make any allocations during gameplay. This avoids pauses while the
user is playing the game and can result in a higher and more consistent
frame rate.
Reduce generation 2 collections by avoiding objects with a medium-length lifetime
Generational garbage collections perform best when you have really
short-lived and/or really long-lived objects in your app. Short lived
objects are collected in the cheaper generation 0 and generation 1
collections, and objects that are long-lived get promoted to generation
2, which is collected infrequently. Long-lived objects are those that
are in use for the entire duration of your app, or during a significant
period of your app, such as during a specific page or game level.
If you frequently create objects that have a temporary lifetime but
live long enough to be promoted to generation 2, then more of the
expensive generation 2 collections happen. You may be able to reduce
generation 2 collections by recycling existing objects or throwing away
objects more quickly.
A common example of objects with medium-term lifetime is objects that
are used for displaying items in a list that a user scrolls through. If
objects are created when items in the list are scrolled into view, and
are no longer referenced as items in the list are scrolled out of view,
then your app typically has a large number of generation 2 collections.
In situations like this you can pre-allocate and reuse a set of objects
for the data that is actively shown to the user, and use short-lived
objects to load info as items in the list come into view.
Reduce generation 2 collections by avoiding large-sized objects with short lifetimes
As mentioned previously, any object that is 85,000 bytes or larger is
allocated on the large object heap (LOH) and gets collected as part of
generation 2. If you have temporary variables, such as buffers, that are
greater than 85,000 bytes, then a generation 2 collection cleans
them up. Limiting temporary variables to less than 85,000 bytes reduces
the number of generation 2 collections in your app. One common technique
is to create a buffer pool and reuse objects from the pool to avoid
large temporary allocations.
Avoid reference-rich objects
The garbage collector determines which objects are live by following
references between objects, starting from roots in your app. For more
info, see What happens during a garbage collection.
If an object contains many references, then there is more work for
the garbage collector to do. A common technique (especially with large
objects) is to convert reference rich objects into objects with no
references (e.g., instead of storing a reference, store an index). Of
course this technique works only when it is logically possible to do
so.
Replacing object references with indexes can be a disruptive and
complicated change to your app and is most effective for large objects
with a large number of references. Do this only if you are noticing
large garbage collection times in your app related to reference-heavy
objects.
Changes to the Garbage collection
Changes made in .Net 4.0:(http://geekswithblogs.net/sdorman/archive/2008/11/07/clr-4.0-garbage-collection-changes.aspx)The .NET garbage collector is one of the areas of the .NET Framework that is extremely important and probably one of the least understood. There are a lot of articles written about it and there have been very few changes since .NET 1.0 was first released. (There have been changes with almost each release, but they have been relatively minor.) With .NET 4.0, however, there are some fairly substantial changes to the GC that will have some interesting performance implications (in a good way). For a quick review, the GC in .NET is a generational garbage collector with 3 generations. Generation 0 and 1 collections are very fast since the segment (called the ephemeral segment) is small while Generation 2 collections can be relatively slow. The GC in .NET also has two modes of operation: Server and Workstation. In Server GC, the algorithm maximizes the overall throughput but all managed code must be paused while it runs. In CLR 4, you can now subscribe to an event to be notified before a Generation 2 or Large Object Heap collection. public static void Main(string[] args) { try { // Register for a set of notifications. // Parameters require tuning. First is // for Gen2, second, Large Object Heap GC.RegisterForFullGCNotification(10, 10); // Start a thread using WaitForFullGCProc Thread thWaitForFullGC = new Thread(new ThreadStart(WaitForFullGCProc)); thWaitForFullGC.Start(); } catch (InvalidOperationException invalidOp) { Console.WriteLine("GC Notifications are not supported while concurrent GC is enabled.\n” + invalidOp.Message); } } public static void WaitForFullGCProc() { while (true) { // Wait for a notification GCNotificationStatus s = GC.WaitForFullGCApproach(); if (s == GCNotificationStatus.Succeeded) { // This call will direct new traffic // away from machine; wait for old // traffic to finish; then call // GC.Collect() OnFullGCApproachNotify(); } // Wait for a notification of completion s = GC.WaitForFullGCComplete(); if (s == GCNotificationStatus.Succeeded) { OnFullGCCompleteEndNotify(); } } The changes in the server GC will probably only affect a small number of applications. However, the changes to the workstation GC (which is the default mode) will affect almost all .NET applications. In all .NET Framework versions from 3.5SP1 and earlier, workstation GC used a concurrent collection method. This means that the GC can do most, but not all, of a Generation 2 collection without pausing managed code. It can’t, however, do a Generation 0 and Generation 1 collection at the same time as a Generation 2 collection. CLR 4.0 changes that to support background collection, which can do a Generation 0 and Generation 1 collection at the same time as a Generation 2 collection. This means that now only unusual circumstances should lead to long latency times. These charts are from some performance testing done by Microsoft and presented during PDC which shows how the new background collection algorithm should greatly reduce the latency times. Background Garbage Collection in CLR 4.0Concurrent GC is being replaced by Background GC in CLR 4.0Concurrent GC is the mode of the GC that you use in desktop applications for example. The goal of the concurrent GC is to minimize pause time, and it does so by allowing you to still allocate while a GC is in progress (hence the concurrent part). Concurrent GC is only available in workstation mode. In server mode (which is what you use in ASP.NET for example when you have multiple processors/cores), simplified all managed calls are paused while in a GC, which means that you can’t allocate anything. This means that the process pauses slightly while in a GC but on the other hand what you loose in pause time, you gain in throughput as GCs are made by x number of GC threads concurrently, where x is #procs*#cores. In concurrent GC you were allowed to allocate while in a GC, but you are not allowed to start another GC while in a GC. This in turn means that the maximum you are allowed to allocate while in a GC is whatever space you have left on one segment (currently 16 MB in workstation mode) minus anything that is already allocated there). The difference in Background mode is that you are allowed to start a new GC (gen 0+1) while in a full background GC, and this allows you to even create a new segment to allocate in if necessary. In short, the blocking that could occur before when you allocated all you could in one segment won’t happen anymore. Background GC’s will be available in the Silverlight CLR as well The CoreCLR uses the same GC as the regular CLR, so this means that Silverlight apps benefit from this as well… As Server mode does not use concurrent GC this will not be available in Server GC Having this in server mode would be incredibly cool as GCs can get pretty hefty, especially in 64 bit apps with very large heaps, but as Maoni mentions in the video and in the post, this work for the concurrent GC lays the foundation for the same work being done in the Server GC. Because of the complexities involved in doing this in Server GC though this is not included in v4.0. If you do have a lot of latency due to heavy pause times during full garbage collections, there is a feature that was introduced in 3.5 SP1 that allows you to be notified when a full GC is about to occur. You can then redirect to another server in a cluster for example while the GC occurs. I just want to mention that this not being in the Server GC does not mean that you should switch your server apps (asp.net etc.) to use workstation with concurrent, Server GC is optimized for these scenarios and should still be used there. |
C# 5.0 : feature set
An Introduction to New Features in C# 5.0
(http://blogs.msdn.com/b/mvpawardprogram/archive/2012/03/26/introduction-of-new-features-in-c-5-0.aspx)
1. C# Evolution MatrixMicrosoft just published a new version of C# : 5.0 beta with CLR version 4.5 (Visual Studio 11 beta).
In order to get a big picture of the whole evolution of C# language, I summarized all the key features
into a C# Evolution Matrix for your reference as below diagram shows:
In C# version 5.0, there are two key features: Async Programming and Caller Information.
2. Async Feature
Two new key words are used for Async feature: async modifier and await operator. Method marked with async modifier is called async method. This new feature will help us a lot in async programming.
For example, in the programming of Winform, the UI thread will be blocked while we use
HttpWebRequest synchronously request any resource in the Internet. From the perspective of user
experience, we cannot interact with the form before the request is done.
private void btnTest_Click(object sender, EventArgs e)
{
var request = WebRequest.Create(txtUrl.Text.Trim());
var content=new MemoryStream();
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
responseStream.CopyTo(content);
}
}
txtResult.Text = content.Length.ToString();
}
In the above example, after we clicked the Test button, we cannot not make any change to the form
before the txtResult textbox shows the result.
In the past, we can also use BeginGetResponse method to send async request as this sample in MSDN
shows:
http://msdn.microsoft.com/zh-cn/library/system.net.httpwebrequest.begingetresponse(v=vs.80).aspx. But it
will takes us a lot effort to realize it.
Now, we can simply use below code to do request asynchronously :
private async void btnTest_Click(object sender, EventArgs e)
{
var request = WebRequest.Create(txtUrl.Text.Trim());
var content = new MemoryStream();
Task responseTask = request.GetResponseAsync();
using (var response = await responseTask)
{
using (var response = await responseTask)
{
using (var responseStream = response.GetResponseStream())
{
Task copyTask = responseStream.CopyToAsync(content);
//await operator to supends the excution of the method until the task
//is completed. In the meantime, the control is returned the UI thread.
await copyTask;
}
}
txtResult.Text = content.Length.ToString();
}
The await operator is applied to the returned task. The await operator suspends execution of themethod until the task is completed. Meanwhile, control is returned to the caller of the suspended
method.
3. Caller Information
Caller Information can help us in tracing, debugging and creating diagnose tools. It will help usto avoid duplicate codes which are generally invoked in many methods for same purpose, such
as logging and tracing.
We could get the below information of caller method :
- CallerFilePathAttribute Full path of the source
file that contains the caller. This is the file path at compile time. - CallerLineNumberAttribute Line number in the
source file at which the method is called. - CallerMemberNameAttribute Method or property
name of the caller.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
InsertLog("Main");
MethodB();
Console.ReadLine();
}
static void MethodA()
{
InsertLog("MethodA");
MethodB();
}
static void MethodB(){ }
static void InsertLog(string methodName)
{
Console.WriteLine("{0} called method B at {1}", methodName, DateTime.Now);
}
}
}
In both Main and MethodA methods, method InsertLog is invoked for logging. Now we can change the codes to be as per below lines:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplicationTest
{
class Program
{
static void Main(string[] args)
{
//InsertLog("Main");
MethodB();
Console.ReadLine();
}
static void MethodA()
{
//InsertLog("MethodA");
MethodB();
}
static void MethodB(
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
InsertLog(memberName);
}
static void InsertLog(string methodName)
{
Console.WriteLine("{0} called method B at {1}", methodName,
DateTime.Now);
}
}
}
C# 3.0 : feature set
Here is a point wise summary of features introduced newly in C# 3.0
Implicitly Typed Local Variables
Implicitly Typed Local Variables
- Local variables can be declared as type ‘var’ which means compiler to determine the actual type based on the data by which its is initialized.
- var i = 10; // i is created of type int
- var name = “MyName” ; // name is created of type string
- can only be used when declared and initialized in same statement.
- Cannot be initialized to null.
- Cannot be used as class members.
- Mostly used to store anonymous types as in LINQ based programming.
- Allow assigning values to any accessible members or properties of a type at the time of initiation without invoking the constructor with parameters.
- The default constructor gets executed before assigning the values.
- E.g. Coordinate c1 = new Coordinate {x=1 , y=2};
- Used in LINQ query expressions along with anonymous types.
- Collection Initializers use Object Initializers to specify multiple elements of collection without calling Add method multiple times.
- Allows adding new methods to existing types without modifying the existing type.
- Are special kind of static methods but are called as if they are instance methods.
- The first parameter passed to Extension methods specifies to which type they operate on preceded by ‘this’ keyword.
- They cannot access the private variables of type which they are extending.
- Extension Methods need to defined in a non-nested and non-generic static class.
- Instance methods take priority over extension methods in case they have same signature.
- Are of class types which can have only public read-only properties as their members. No other class members like methods are allowed.
- They are of reference types and are derived from ‘Object’ class.
- Internally compiler gives them the name but its not accessible by application code.
- They have a method scope.
- Can be initiated directly e.g. new { property1=1, property2=”Hello World”};
- Very similar to anonymous methods introduced in C# 2.0.
- Its an inline expression or statement block which can be used to pass arguments to method call or assign value to delegate.
- All lambda expression use lambda operator => where the left side denotes result and right contains statement block or expression.
- Helps in simplifying property declaration in cases where there is no custom logic required in accessors methods.
- E.g. public int Price {get; set;};
- Internally compiler creates an anonymous field for assigning values.
Jan 9, 2013
.net Profiling - Part III -- Resource List
Visual Studio Toolbox: Performance Profiling : http://channel9.msdn.com/ Shows/Visual-Studio-Toolbox/ Visual-Studio-Toolbox- Performance-Profiling
Silverlight Firestarter 2010 Session 6 - Tune Your Application: Profiling and Performance Tips : http://channel9.msdn.com/ Series/Silverlight- Firestarter/Silverlight- Firestarter-2010-Session-6- Tune-Your-Application- Profiling-and-Performance-Tips
Visualizing Concurrency: VS 2010 Beta 2 - Parallel Performance Profiling Advancements : http://channel9.msdn.com/ shows/Going+Deep/Visualizing- Concurrency-Inside-the- Concurrency-Visualizer- Profiling-Tool/
Microsoft Visual Studio IntelliTrace, Test Impact Analysis and Tier Interaction Profiling : http://channel9.msdn.com/ Events/PDC/PDC10/FT05
Profiling and Debugging Parallel Code with Microsoft Visual Studio 2010 : http://channel9.msdn.com/ Events/TechEd/NorthAmerica/ 2010/DEV317
SC08: Windows HPC: Multi-core Parallel Code Profiling in VS2010 : http://channel9.msdn.com/ shows/The+HPC+Show/SC08- Windows-HPC-Multi-core- Parallel-Code-Profiling-in- VS2010/
Ian Huff - Using VSTS Performance Tools to Speed Up Your App (Part 1) : http://channel9.msdn.com/ Blogs/TheChannel9Team/Ian- Huff-Using-VSTS-Performance- Tools-to-Speed-Up-Your-App- Part-1
Ian Huff - Using VSTS Performance Tools to Speed Up Your App (Part 2) : http://channel9.msdn.com/ Blogs/TheChannel9Team/Ian- Huff-Using-VSTS-Performance- Tools-to-Speed-Up-Your-App- Part-2
CPU Sampling using Visual Studio 2010 Performance Analyzer Tool : http://channel9.msdn.com/ Blogs/wriju/CPU-Sampling- using-Visual-Studio-2010- Performance-Analyzer-Tool
The zen of async: Best practices for best performance : http://channel9.msdn.com/ Events/BUILD/BUILD2011/TOOL- 829T
------------------------------
Defrag Tools Series:
Defrag Tools: #1 - Building your USB thumbdrive
Defrag Tools: #2 - Process Explorer : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-2-Process-Explorer
Defrag Tools: #3 - Process Monitor : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-3-Process-Monitor
Defrag Tools: #4 - Process Monitor - Examples
Defrag Tools: #5 - Autoruns and MSConfig : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-5-Autoruns
Defrag Tools: #6 - RAMMap : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-6-RAMMap
Defrag Tools: #7 - VMMap : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-7-VMMap
Defrag Tools: #8 - Mark Russinovich : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-8-Mark-Russinovich
Defrag Tools: #9 - ProcDump : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-9-ProcDump
Defrag Tools: #10 - ProcDump - Triggers : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-10-ProcDump-Triggers
Defrag Tools: #11 - ProcDump - Windows 8 & Process Monitor : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-11-ProcDump-Windows-8-- Process-Monitor
Defrag Tools: #12 - TaskMgr and ResMon : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-12-TaskMgr-and-ResMon
Defrag Tools: #13 - WinDbg : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-13-WinDbg
Defrag Tools: Live - //build/ 2012 : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-Live-Build2012
Defrag Tools: #14 - WinDbg - SOS : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-14-WinDbg-SOS
Defrag Tools: #15 - WinDbg - Bugchecks (BSOD) : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-15-WinDbg-Bugchecks
Defrag Tools: #16 - WinDbg - Driver Verifier : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-16-WinDbg-Driver- Verifier
Defrag Tools: #17 - WinDbg - Driver Verifier - Part 2 : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-17-WinDbg-Driver- Verifier-Part-2
Defrag Tools: #18 - WinDbg - Driver Verifier - Part 3 : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-18-WinDbg-Driver- Verifier-Part-3
Defrag Tools: #19 - WinDbg - OCA : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-19-WinDbg-OCA
Defrag Tools: #20 - WinDbg - Basic Commands : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-20-WinDbg-Basic-Commands
Defrag Tools: #21 - WinDbg - Memory User Mode : http://channel9.msdn.com/ Shows/Defrag-Tools/Defrag- Tools-21-WinDbg-Memory-User- Mode
------------------------------
ASP.Net
Bigger, Faster, Stronger: Optimizing ASP.NET Applications : http://channel9.msdn.com/ events/MIX/MIX11/FRM04
Bundling and Optimizing : http://channel9.msdn.com/ Events/aspConf/aspConf/ Bundling-and-Optimizing
Optimize your website using ASP.NET and IIS8: http://channel9.msdn.com/ events/BUILD/BUILD2011/SAC- 837T
Building High Performance Web Applications with the Windows Azure Platform : http://channel9.msdn.com/ Events/PDC/PDC10/CS01
Improving-ASPNET-MVC- Application-Performance: http://channel9.msdn.com/ Series/mvcConf/mvcConf-2- Steven-Smith-Improving-ASPNET- MVC-Application-Performance
------------------------------PerfView Tutorial
Tutorial-0-Getting-PerfView: http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-0-Getting- PerfView
Tutorial-1-Collecting-data- with-the-Run-command: http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-1- Collecting-data-with-the-Run- command
Tutorial-2-A-Simple-CPU- Performance-Investigation : http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-2-A-Simple- CPU-Performance-Investigation
Tutorial-3-Resolving-Symbols : http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-3-Resolving- Symbols
Tutorial-4-Grouping-And- Folding : http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfVIew-Tutorial-4-Grouping- And-Folding
Tutorial-5-Drilling-Into- Feature : http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-5-Drilling- Into
Tutorial-6-The-Event-Viewer- Basics: http://channel9.msdn.com/ Series/PerfView-Tutorial/ Perfview-Tutorial-6-The-Event- Viewer-Basics
Tutorial-7 - Using-the-Event-Viewer-in- ASPNET-Scenarios:
http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-7-Using-the- Event-Viewer-in-ASPNET- Scenarios
Tutorial-8-Generating-Your- Own-Events-with-EventSources : http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-8- Generating-Your-Own-Events- with-EventSources
Tutorial-9-NET-Memory- Investigation-Basics-of-GC- Heap-Snapshots : http://channel9.msdn.com/ Series/PerfView-Tutorial/ PerfView-Tutorial-9-NET- Memory-Investigation-Basics- of-GC-Heap-Snapshots
Tutorial-10-Investigating-NET- Heap-Memory-Leaks-Part1- Collecting-the-data : http://channel9.msdn.com/ Series/PerfView-Tutorial/ Tutorial-10-Investigating-NET- Heap-Memory-Leaks-Part1- Collecting-the-data
Tutorial-11-Investigating-NET- Heap-Memory-Leaks-Part2- Analyzing-the-data : http://channel9.msdn.com/ Series/PerfView-Tutorial/ Tutorial-11-Investigating-NET- Heap-Memory-Leaks-Part2- Analyzing-the-data
Tutorial-12-Wall-Clock-Time- Investigation-Basics : http://channel9.msdn.com/ Series/PerfView-Tutorial/ Tutorial-12-Wall-Clock-Time- Investigation-Basics
Tutorial-13-Leveraging-Tasks- make-sense-of- ParallelAsynchronous-programs : http://channel9.msdn.com/ Series/PerfView-Tutorial/ Tutorial-13-Leveraging-Tasks- make-sense-of- ParallelAsynchronous-programs
----------------------------------------------------------
.Net Best Practices:
.NET Best Practice No: 1:- Detecting High Memory consuming functions in .NET code : http://www.codeproject.com/Articles/45292/NET-Best-Practice-No-1-Detecting-High-Memory-cons.NET Best Practice No: 2:- Improve garbage collector performance using finalize/dispose pattern : http://www.codeproject.com/Articles/39246/NET-Best-Practice-No-2-Improve-garbage-collector
.NET Best Practice No: 3:- Using performance counters to gather performance data: http://www.codeproject.com/Articles/42001/NET-Best-Practice-No-3-Using-performance-counters
.Net Best Practice No 4:- Improve bandwidth performance of ASP.NET sites using IIS compression : http://www.codeproject.com/Articles/42391/Best-Practice-No-4-Improve-bandwidth-performance-o
.Net Best Practices No 5: - Detecting .NET application memory leaks : http://www.codeproject.com/Articles/42721/Best-Practices-No-5-Detecting-NET-application-memo
------------------------------
Book on performance testing: The Complete Guide to .NET Performance Testing and Optimization
Subscribe to:
Posts (Atom)