Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Threading -- Performance

Threading -- Performance

Scheduled Pinned Locked Moved C#
csssysadminperformancehelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    petst
    wrote on last edited by
    #1

    Hi all, An interresting problem in the context of interprocess communication. Consider following code: public void StartSepThread() { ThreadStart tsThread = new ThreadStart(RunServerSepThread); TestThread = new Thread(tsThread); TestThread.Name = "IPC.Test"; TestThread.Start(); } public void RunServerSepThread() { while(true) { (lot of code here...) } } The code above proves to be 50% less performant than following code: public void RunServerSameThread() { while(true) { (exact same code here...) } } When running the server in the same thread, we are able to move 163 Mbit/sec of data between two running processes. However, when running the same code as a seperate thread, performance goes down by almost 35% to a level of 111 Mbit/sec. Anybody any idea what this might be??? Thanks

    S 1 Reply Last reply
    0
    • P petst

      Hi all, An interresting problem in the context of interprocess communication. Consider following code: public void StartSepThread() { ThreadStart tsThread = new ThreadStart(RunServerSepThread); TestThread = new Thread(tsThread); TestThread.Name = "IPC.Test"; TestThread.Start(); } public void RunServerSepThread() { while(true) { (lot of code here...) } } The code above proves to be 50% less performant than following code: public void RunServerSameThread() { while(true) { (exact same code here...) } } When running the server in the same thread, we are able to move 163 Mbit/sec of data between two running processes. However, when running the same code as a seperate thread, performance goes down by almost 35% to a level of 111 Mbit/sec. Anybody any idea what this might be??? Thanks

      S Offline
      S Offline
      Salil Khedkar
      wrote on last edited by
      #2

      Ummm... Just in case you have misssed this, try Thread.Sleep(0); immediately after you do TestThread.Start(); method. Do post the resultant performance. ;) MSDN documentation on System.Threading.Thread overview says "On a uniprocessor machine, the (child) thread does not get any processor time until the main thread yields."

      P 1 Reply Last reply
      0
      • S Salil Khedkar

        Ummm... Just in case you have misssed this, try Thread.Sleep(0); immediately after you do TestThread.Start(); method. Do post the resultant performance. ;) MSDN documentation on System.Threading.Thread overview says "On a uniprocessor machine, the (child) thread does not get any processor time until the main thread yields."

        P Offline
        P Offline
        petst
        wrote on last edited by
        #3

        Well... the performance gain is nothing. I didn't mentio it in my code posted, but inside the While loop there is a blocking call. This is exactly the same code in the single thread and new thread code. So that doesn't make any difference. I believe the CPU would go 100% if no blocking call was inside the loop and Thread.Sleep(0) was missing... Thanks Peter

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups