Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limits of Optimizer Multi-Threading

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Limits of Optimizer Multi-Threading

    Hello,

    I built a work station with the following: AMD Ryzen 1950X, 16 cores, 32 threads, 32 GB RAM DD4 3200.
    I don't know what's going on but CPU usage doesn't go beyond 50% when I optimize a strategy with 10x 5 variables (see attached).
    My other computer I7,4 cores, 8GB RAM is faster using the same strategy.

    Jim from Ninjatrader customer service has a similar hardware and was able to crank it up to over 70%, according to this post.
    https://ninjatrader.com/support/foru...ulti-threading

    Is there a limitation in windows, or AMD Ryzen Master platform that I can tweak and use full performance of my computer?



    #2
    Hello YakusaTrader,

    Thanks for your post.

    This sounds like a difference between Ryzen and Intel architectures.

    In the linked thread I had tested with the SampleMACrossover strategy. We can expect differences between each strategy that we optimize as each strategy may have a different complexity of calculations and the strategy's use of variables could add more utilization of RAM. Ryzen is known to be slower with memory and instructions per clock compared with Intel, so these factors could be attributing to the differences you see.

    You could set up an apples-to-apples test with the SampleMACrossover strategy and you will likely get the same or better performance when I tested.

    The SampleMACrossover strategy uses IsInstantiatedOnEachOptimizationIteration = false, so it is leaner on memory impact. This could result in a performance boost on Ryzen considering memory would not be as much of a factor in the optimization.

    I do not have anything scientific to share, but could suggest the following to get the most out of the optimization and to analyze the strengths that each processor may have. We know that more threads means more optimization iterations at once, so we could focus on the following to see the differences between the hardware.

    1. Program the strategy so it can use IsInstantiatedOnEachOptimizationIteration = false so it can have the best performance from a software standpoint.
    2. Create a test strategy that adds several variables and is not very complex in calculations. This strategy would be used to observe memory impact on each PC. Test this with and without IsInstantiatedOnEachOptimizationIteration = false
    3. Create a test strategy that does not add many variables but does some complex mathematical operations. This strategy would be used to observe the performance impact of the processor's instructions per clock.

    More information on using IsInstantiatedOnEachOptimizationIteration = false can be found here - https://ninjatrader.com/support/help...niteration.htm

    I look forward to being of any further assistance.
    Last edited by NinjaTrader_Jim; 02-21-2019, 10:25 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim, I have tested 2 and 3 in the past and I can confirm that memory usage spikes when a strategy becomes more complex (a lot variable to be stored).
      In my case, the strategy I am using doesn't store a lot of variables and as you can see in the picture, memory usage remains below 20%.

      I have to test 1, to see if it improves speed.

      Since my RAM usage is below 20%, do you know if that metric in resource manager is the only good measure for RAM?

      Comment


        #4
        Hello YakusaTrader,

        Task Manager or a resource monitor will show the impact of the amount of memory that is being used. This would be an accurate measure. The idea for the tests would be to try to narrow down what sort of operations affect the optimization performance between the different CPU's to see their strengths.

        As for getting the most from a software standpoint, we could only recommend using IsInstantiatedOnEachOptimizationIteration = false and writing the strategy to be more efficient.

        Let me know if there is anything else I can do to help.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by YakusaTrader View Post
          Hello,

          I built a work station with the following: AMD Ryzen 1950X, 16 cores, 32 threads, 32 GB RAM DD4 3200.
          I don't know what's going on but CPU usage doesn't go beyond 50% when I optimize a strategy with 10x 5 variables (see attached).
          My other computer I7,4 cores, 8GB RAM is faster using the same strategy.

          Jim from Ninjatrader customer service has a similar hardware and was able to crank it up to over 70%, according to this post.
          https://ninjatrader.com/support/foru...ulti-threading

          Is there a limitation in windows, or AMD Ryzen Master platform that I can tweak and use full performance of my computer?

          Same issue here.. only with AMD RYZEN (my intel i9 is flying..)

          Click image for larger version

Name:	2021-01-17_18-00-20.png
Views:	73
Size:	115.0 KB
ID:	1137083
          Attached Files
          Last edited by Oracletrades; 01-17-2021, 07:00 AM.

          Comment


            #6
            Hello Oracletrades,

            I am not sure how you are testing, but it would be helpful to share your results like I have in the other thread using the SampleMACrossover strategy since it takes the software level steps to be as performant as possible as it it is compliant with IsInstantiatedOnEachOptimizationIteration = false. In that thread, I tested ES 1 minute data for 1 year with 1;200;1 for the fast and slow periods.

            Intel CPUs are known for having more instructions per clock. If you have some information to share regarding i9 CPU's and Ryzen CPU's running some controlled optimization tests with SampleMACrossover, I am sure many other on the forum would like to hear your results.

            I'm not aware of any setting that can be made to "turn up" utilization on various CPU's, but I would focus my tests using SampleMACrossover as a control. These are different CPU's so difference in performance would not be out of the ordinary, but if you perform a test like I have in the other thread, I would expect to see similar results on your Ryzen CPU.

            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              Hi Jim,

              thanks for taking the time to respond. I took a video of the above but with MNQ as I didn't want to have to download all the ES data. My Hardware
              • CPU AMD RYZEN 3900X 12 core
              • 32 GB DDR 4 RAM 4000MHZ
              • 2 TB NVME HD
              • NVIDIA GeForce RTX 2060
              • 250 MBIT/s internet connection
              ...no other applications running other than snagit to record the video.
              The video is 8MB which seems to be too much for your website to accept (really...?).
              Hence the onedrive link here: https://1drv.ms/v/s!AmwmhtCvgNorgYC3...yGnpU?e=Bwkubo

              Observations:
              • my strategies that run through the optimizer are always set up with "IsInstantiatedOnEachOptimizationIteration = false". Learned that the hard way...
              • I appreciate that a simple MA strategy with 2 parameters "flies" through the optimizer, but that's just not a real-life challenge, appreciate it's only for testing your and my environment to ensure we're not having huge differences with a basic strategy.
              • Even 60% CPU usage is "wasting" nearly half the power of my machine (why...). I appreciate you don't want to crash the machine but maybe 80% would still be manageable?
              • my strategy has more variables and ranges to test and runs with max 18% CPU usage, an absolute joke... Screenshot below.

              What's your view please?


              Click image for larger version

Name:	2021-01-18_11-12-33.png
Views:	78
Size:	925.8 KB
ID:	1137217

              Comment


                #8
                ...just on a side note... I spent nearly $2000 USD for this machine with the dominant purpose to improve optimizations with NT8.. you can imagine my frustration...

                Comment


                  #9
                  Hello Oracletrades,

                  NinjaTrader does not decide if it will use 60% or 80% of a core when optimizing. Different strategies can have differing complexity, and each optimization iteration will process on one logical core. We also have to consider time to queue up data for tests, and if memory is fully utilized we will have to wait for garbage collection to decommit some memory so the test can keep going. (Running out of memory does not appear to be an issue in your video.)

                  It is entirely possible that one strategy will utilize more processing time at once than another strategy or another optimization. With the parameters different, different code paths may be taken and some optimization iterations will not use as much CPU time as others. I would not have the expectation that the CPU will be 100% utilized at all times, but I would expect that the performance is being distributed across all logical cores. Using 100% of the CPU is a best case scenario, but may not be seen in all optimizations.

                  I ran another lengthy optimization with SampleMACrossover on my home PC and I have posted screenshots of my results here. Once the optimizer has been running for about a minute and a half, I see the CPU consumption I would expect to see. I will also note that this operation is taking much longer on my end than it is on yours, and your CPU is several generations newer. If you make the test more intensive by including more data and more parameters, and let the optimization run as long as I have in my screenshot, I would expect to see higher utilization with your test.

                  In general, comparing your video to my test, your video appears to not have any trouble with this operation while my PC is working harder to complete it, so I would see higher utilization than you.

                  Past this, if you want to further understand how the different code paths in your strategy affect optimization performance, you can make the SampleMACrossover test more lengthy and abusive until you get as much CPU utilization as you can, and then you can implement parts of your strategy in a copy of the SampleMACrossover strategy so you can observe how the different logic would take more or less CPU time.

                  Please let me know if there is anything else I can do to help.
                  Attached Files
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Jim, appreciate you going the "extra mile" with your home PC... I do think the code has to do with it. I am not a developer but I did streamline some of the code and that got the CPU to 40-50% overall utilization. So for now, I'm happy with that. I just think that with a strategy so complex, each core has enough to do but that's just me thinking, I guess.

                    RAM Is not an issue and all historical data is available offline so no need to wait for downloads etc...

                    I may commission a pro to take a lot at my code and help optimize further!

                    Thanks for now!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by tgn55, Today, 09:51 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post tgn55
                    by tgn55
                     
                    Started by cxxazssx, Today, 09:45 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post cxxazssx  
                    Started by southpacific001, 02-26-2021, 09:25 PM
                    14 responses
                    64 views
                    0 likes
                    Last Post REI140205  
                    Started by punkiy2111, Today, 05:22 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post punkiy2111  
                    Started by secrettrader, Today, 03:36 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post secrettrader  
                    Working...
                    X