Пример #1
0
        /*
         * consumer stub throughput ratings
                10000 at 940 ms. tp 1 at ,09ms :: internal module throughput (same appdomain)
                10000 at 3722 ms. tp 1 at ,37 :: external module throughput (cross appdomain)
         * 
         */
        public Broker(RestartApplication restartApp = null, RestartApplication resetBroker = null)
        {
            this.restartApp = restartApp;
            this.resetBroker = resetBroker;

            logger.Debug("intitialising broker");
            // logger for modules only
            ModulesLogger = new TaskBroker.Logger.CommonTape(new Logger.LoggerEndpoint[]{
                new Logger.ConsoleEndpoint()
            });

            ClearConfiguration();

            Statistics = new StatHub();
            Scheduler = new TaskScheduler.ThreadPool();
            AssemblyHolder = new Assemblys.AssemblyPackages();

            MaintenanceTasks = new List<PlanItem>()
            {
                // include statistic flush task
                new PlanItem(){
                     intervalType = IntervalType.intervalSeconds,
                     intervalValue = 15,
                     NameAndDescription="statistic maintenance task",
                     JobEntry = (ThreadContext ti, PlanItem pi)=>{ Statistics.FlushRetairedChunks(); return 1;
                     }
                },
                // 
                //new PlanItem(){
                //     intervalType = IntervalType.intervalSeconds,
                //     intervalValue = 30,
                //     NameAndDescription="assemblies maintenance task",
                //     JobEntry = (ThreadContext ti, PlanItem pi)=>
                //     { 
                //         AssemblyHolder.assemblySources.FetchAllIfRequired();
                //         AssemblyHolder.assemblySources.BuildAllIfRequired();
                //         AssemblyHolder.assemblySources.UpdateAllIfRequired();
                //     }
                //}

                // TODO:
                // performance tune
                // by channel level growing -> increment tasks for channel -> increment working threads
                // check for throughput if doesn't change -> rollback to default execution plan
                //new PlanItem(){
                //     intervalType = IntervalType.intervalSeconds,
                //     intervalValue = 10,
                //     NameAndDescription="channel throughput tune",
                //     planEntry = (ThreadItem ti, PlanItem pi)=>{  }
                //}
                // with 10sec interval->update quilifier
                // with 30sec with quilifier data do recommendations from recommedationsHub
            };

            Modules = new ModHolder(this);

            QueueInterfaces = new QueueClassificator();

            Configurations = new ConfigurationDepot();
        }
Пример #2
0
        static void Scheduler_PayloadToOverallTime_VScale(
            uint step
            , uint steps
            , uint jobsCount
            , uint ThreadsCount
            , uint stepSyncFactor)// interlock granulation actually
        {
            TaskScheduler.ThreadPool Scheduler = new TaskScheduler.ThreadPool(ThreadsCount);


            TimeSpan cspan = new TimeSpan();


            //uint localVar = 0, incVal = 10, maxVal = 10000000;
            int localVar = 0, incVal = (int)step, maxVal = (int)(step * steps), syncStep = (int)(step / stepSyncFactor);

            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < maxVal; i++)
            {
                localVar++;
                //System.Threading.Interlocked.Increment(ref localVar);
                //if (localVar % incVal == 0)
                //    System.Threading.Thread.Sleep(0);
            }
            cspan = sw.Elapsed;
            //Console.WriteLine(cspan.TotalMilliseconds);

            //			sw = Stopwatch.StartNew();
            //			for (int i = 0; i < maxVal; i++) {
            //				localVar++;
            //			}
            //			cspan = sw.Elapsed;
            //			Console.WriteLine(cspan.TotalMilliseconds);

            localVar = 0;
            bool      notSucceeded = true;
            Stopwatch swx_parallel = null;
            {
                Thread[] ths = new Thread[steps];
                swx_parallel = Stopwatch.StartNew();
                for (int i = 0; i < steps; i++)
                {
                    ths[i] = new Thread(() =>
                    {
                        //for (int x = 0; x < incVal; x++)
                        //{
                        //    System.Threading.Interlocked.Increment(ref localVar);
                        //}
                        int tempInc = 0;
                        for (int x = 0; x < syncStep; x++)
                        {
                            for (int y = 0; y < stepSyncFactor; y++)
                            {
                                tempInc++;
                            }
                            Interlocked.Add(ref localVar, tempInc);
                            tempInc = 0;
                        }
                        if (localVar >= maxVal)
                        {
                            notSucceeded = false;
                        }
                    });
                    ths[i].Start();
                }
                while (notSucceeded)
                {
                    System.Threading.Thread.Sleep(0);
                }
                swx_parallel.Stop();
            }
            TimeSpan payloadspan_parallel = swx_parallel.Elapsed;

            localVar     = 0;
            notSucceeded = true;

            PlanItemEntryPoint job = (ThreadContext ti, PlanItem pi) =>
            {
                //Console.WriteLine("ex started {0} {1}", ti.hThread.Name, localVar);
                //for (int i = 0; i < incVal; i++)
                //{
                //    //localVar++;
                //    System.Threading.Interlocked.Increment(ref localVar);
                //}
                int tempInc = 0;
                for (int x = 0; x < syncStep; x++)
                {
                    for (int y = 0; y < stepSyncFactor; y++)
                    {
                        tempInc++;
                    }
                    Interlocked.Add(ref localVar, tempInc);
                    tempInc = 0;
                }
                //System.Threading.Thread.Sleep(0);
                if (localVar >= maxVal)
                {
                    notSucceeded = false;
                }
                //Console.WriteLine("succ executed");
                return(-1);
            };

            List <PlanItem> TaskList = new List <PlanItem>();

            for (int i = 0; i < jobsCount; i++)
            {
                TaskList.Add(new PlanItem()
                {
                    intervalType       = TaskUniversum.Task.IntervalType.withoutInterval,
                    NameAndDescription = "",
                    JobEntry           = job
                });
            }

            //Console.WriteLine("jobs: {0}", TaskList.Count);

            Stopwatch swx = Stopwatch.StartNew();

            Scheduler.SetPlan(TaskList);
            Scheduler.ReWake();

            while (notSucceeded)
            {
                System.Threading.Thread.Sleep(0);
            }
            swx.Stop();
            TimeSpan payloadspan = swx.Elapsed;

            Scheduler.SuspendAll();
            //Console.WriteLine("e act");
            while (Scheduler.Activity)
            {
                System.Threading.Thread.Sleep(0);
            }

            //

            //Console.WriteLine("{0} by {2} --- {3:.00} :: {4} {5} {6} {7}",
            //Console.WriteLine("{0} {2} {9:.00} {3:.00} {8:.00} {4} {5} {6} {7}",
            //    cspan.TotalMilliseconds, cspan.TotalMilliseconds,// * (maxVal / incVal),
            //    payloadspan.TotalMilliseconds,
            //    //(payloadspan.TotalMilliseconds * (maxVal / incVal)) / cspan.TotalMilliseconds);
            //    payloadspan.TotalMilliseconds / cspan.TotalMilliseconds,
            //     step, steps, jobsCount, ThreadsCount,
            //     payloadspan.TotalMilliseconds / payloadspan_parallel.TotalMilliseconds,
            //     payloadspan_parallel.TotalMilliseconds);

            Console.WriteLine("{0:0.00} {1:0.00} {2:0.00} {3:0.00} {4:0.00} {5} {6} {7}"
                              , cspan.TotalMilliseconds
                              , payloadspan.TotalMilliseconds
                              , payloadspan_parallel.TotalMilliseconds
                              , payloadspan.TotalMilliseconds / cspan.TotalMilliseconds
                              , payloadspan.TotalMilliseconds / payloadspan_parallel.TotalMilliseconds
                              , jobsCount
                              , ThreadsCount
                              , stepSyncFactor);
        }
Пример #3
0
        static void Scheduler_PayloadToOverallTime()
        {
            TaskScheduler.ThreadPool Scheduler = new TaskScheduler.ThreadPool();

            TimeSpan cspan = new TimeSpan();


            uint localVar = 0, incVal = 10, maxVal = 10000;

            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < maxVal; i++)
            {
                localVar++;
                if (localVar % incVal == 0)
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
            cspan = sw.Elapsed;
            Console.WriteLine(cspan.TotalMilliseconds);

            //			sw = Stopwatch.StartNew();
            //			for (int i = 0; i < maxVal; i++) {
            //				localVar++;
            //			}
            //			cspan = sw.Elapsed;
            //			Console.WriteLine(cspan.TotalMilliseconds);

            localVar = 0;

            bool notSucceeded      = true;
            PlanItemEntryPoint job = (ThreadContext ti, PlanItem pi) =>
            {
                //Console.WriteLine("ex started {0} {1}", ti.hThread.Name, localVar);
                for (int i = 0; i < incVal; i++)
                {
                    localVar++;
                }
                System.Threading.Thread.Sleep(1);
                if (localVar >= maxVal)
                {
                    notSucceeded = false;
                }
                //Console.WriteLine("succ executed");
                return(-1);
            };
            List <PlanItem> TaskList = new List <PlanItem>()
            {
                new PlanItem()
                {
                    intervalType       = TaskUniversum.Task.IntervalType.withoutInterval,
                    NameAndDescription = "",
                    JobEntry           = job
                },
            };


            Scheduler.ReWake();
            Stopwatch swx = Stopwatch.StartNew();

            Scheduler.SetPlan(TaskList);

            while (notSucceeded)
            {
                System.Threading.Thread.Sleep(0);
            }
            TimeSpan payloadspan = swx.Elapsed;

            Scheduler.SuspendAll();
            Console.WriteLine("e act");
            //while (Scheduler.Activity)
            //{
            //}

            //

            Console.WriteLine("{0}({1}) by {2} --- {3:.00}",
                              cspan.TotalMilliseconds, cspan.TotalMilliseconds, // * (maxVal / incVal),
                              payloadspan.TotalMilliseconds,
                                                                                //(payloadspan.TotalMilliseconds * (maxVal / incVal)) / cspan.TotalMilliseconds);
                              payloadspan.TotalMilliseconds / cspan.TotalMilliseconds);
        }