Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:05:51+00:00 2026-05-31T10:05:51+00:00

I have a WCF service that uses LINQ to SQL for its data layer.

  • 0

I have a WCF service that uses LINQ to SQL for its data layer. Only stored procedures are in use, no dynamic table access. When I target x64, I am getting half the throughput of an x86 build. I have traced the hot path to Reflection.Emit.DynamicMethod.CreateDelegate. I created a simple test project to demonstrate the difference in performance between the two platforms.

What is the specific explanation for DynamicMethod being so much slower on x64? My vague understanding is that there may be an additional thunk involved in DynamicInvoke on x64.


Here are the results when performed on Windows 7 Enterprise x64, Core i7 Q720 @ 1.60 GHz, single-threaded:

Build Target      Average milliseconds to execute 100,000 iterations
x86               5504
x64               14699
Any CPU           14789

And the test code:

class Program
{
    private delegate string XInvoker(string arg);

    private const int OUTER_ITERATIONS = 4;
    private const int INNER_ITERATIONS = 100000;

    static void Main(string[] args)
    {
        Console.WriteLine("Timing {0} iterations, repeat {1} times...", INNER_ITERATIONS, OUTER_ITERATIONS);

        var watch = new Stopwatch();
        long totalMs = 0;

        for (int outer = 0; outer < OUTER_ITERATIONS; outer++)
        {
            watch.Restart();

            for (int inner = 0; inner < INNER_ITERATIONS; inner++)
            {
                var method = new DynamicMethod("X", typeof(string), new[] { typeof(string) });

                var ilGen = method.GetILGenerator();
                ilGen.Emit(OpCodes.Ldarg_0);
                ilGen.Emit(OpCodes.Ret);

                var del = method.CreateDelegate(typeof(XInvoker));
                var blah = del.DynamicInvoke("blah");
            }

            watch.Stop();
            totalMs += watch.ElapsedMilliseconds;

            Console.WriteLine("Took {0} ms to iterate {1} times", watch.ElapsedMilliseconds, INNER_ITERATIONS);
        }

        Console.WriteLine();
        Console.WriteLine("Overall average: {0} ms to iterate {1} times", totalMs / OUTER_ITERATIONS, INNER_ITERATIONS);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:05:53+00:00Added an answer on May 31, 2026 at 10:05 am

    I would guess it’s to do with the speed of compilation. There are lots of threads that seem to indicate JIT compiling for x64 is significanltly slower than x86.

    In this one case someone saw significant performance increase in their x64 JIT just because other dependent assemblies weren’t NGEN’d. Although I doubt it would help in this scenario, you never know what other things it is trying to load that might be slowing it down. Perhaps try running the command in the answer and see if that changes your performance.
    WPF slow to start on x64 in .NET Framework 4.0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have client application that uses WCF service to insert some data to backend
I have a Data Service created using WCF that internally uses nHibernate. This WCF
I'm currently writing a WCF web service that uses LINQ to SQL to fetch
We have a WCF service that uses Entity Framework to query a SQL database.
I have a WCF service that uses ODP.NET to read data from an Oracle
I have a WCF service that uses basicHttpbinding in development. Now in product we
I have a WCF service that uses a System.ServiceModel.Syndication.SyndicationFeed to create an RSS feed.
I have a WCF service that uses X.509 certificates for authentication. What's the best
I have a wcf service that uses the .net System.AddIns framework to load assemblies
I have an wcf service that is hosted in II6. The service uses the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.