示例#1
0
        private void RemoveProcessorFromPotentialIdleStep(StageExecution execution)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (org.neo4j.helpers.collection.Pair<Step<?>,float> fast : execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, true))
            foreach (Pair <Step <object>, float> fast in execution.StepsOrderedBy(Keys.avg_processing_time, true))
            {
                int numberOfProcessors = fast.First().processors(0);
                if (numberOfProcessors == 1)
                {
                    continue;
                }

                // Translate the factor compared to the next (slower) step and see if this step would still
                // be faster if we decremented the processor count, with a slight conservative margin as well
                // (0.8 instead of 1.0 so that we don't decrement and immediately become the bottleneck ourselves).
                float factorWithDecrementedProcessorCount = fast.Other() * numberOfProcessors / (numberOfProcessors - 1);
                if (factorWithDecrementedProcessorCount < 0.8f)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> fastestStep = fast.first();
                    Step <object> fastestStep = fast.First();
                    long          doneBatches = Batches(fastestStep);
                    if (BatchesPassedSinceLastChange(fastestStep, doneBatches) >= _config.movingAverageSize())
                    {
                        int before = fastestStep.Processors(0);
                        if (fastestStep.Processors(-1) < before)
                        {
                            _lastChangedProcessors[fastestStep] = doneBatches;
                            return;
                        }
                    }
                }
            }
        }
示例#2
0
        public static void PrintSpectrum(StringBuilder builder, StageExecution execution, int width, DetailLevel additionalStatsLevel)
        {
            long[] values = values(execution);
            long   total  = total(values);

            // reduce the width with the known extra characters we know we'll print in and around the spectrum
            width -= 2 + PROGRESS_WIDTH;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> bottleNeck = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator().next();
            Pair <Step <object>, float> bottleNeck = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next();
            QuantizedProjection         projection = new QuantizedProjection(total, width);
            long lastDoneBatches = 0;
            int  stepIndex       = 0;
            bool hasProgressed   = false;

            builder.Append('[');
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
            foreach (Step <object> step in execution.Steps())
            {
                StepStats stats = step.Stats();
                if (!projection.Next(values[stepIndex]))
                {
                    break;                              // odd though
                }
                long stepWidth = total == 0 && stepIndex == 0 ? width : projection.Step();
                if (stepWidth > 0)
                {
                    if (hasProgressed)
                    {
                        stepWidth--;
                        builder.Append('|');
                    }
                    bool   isBottleNeck   = bottleNeck.First() == step;
                    string name           = (isBottleNeck ? "*" : "") + stats.ToString(additionalStatsLevel) + (step.Processors(0) > 1 ? "(" + step.Processors(0) + ")" : "");
                    int    charIndex      = 0;                      // negative value "delays" the text, i.e. pushes it to the right
                    char   backgroundChar = step.Processors(0) > 1 ? '=' : '-';
                    for (int i = 0; i < stepWidth; i++, charIndex++)
                    {
                        char ch = backgroundChar;
                        if (charIndex >= 0 && charIndex < name.Length && charIndex < stepWidth)
                        {
                            ch = name[charIndex];
                        }
                        builder.Append(ch);
                    }
                    hasProgressed = true;
                }
                lastDoneBatches = stats.Stat(Keys.done_batches).asLong();
                stepIndex++;
            }

            long progress = lastDoneBatches * execution.Config.batchSize();

            builder.Append("]").Append(FitInProgress(progress));
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOrderStepsDescending()
        public virtual void ShouldOrderStepsDescending()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Collection<Step<?>> steps = new java.util.ArrayList<>();
            ICollection <Step <object> > steps = new List <Step <object> >();

            steps.Add(stepWithAverageOf("step1", 0, 10));
            steps.Add(stepWithAverageOf("step2", 0, 5));
            steps.Add(stepWithAverageOf("step3", 0, 30));
            steps.Add(stepWithAverageOf("step4", 0, 5));
            StageExecution execution = new StageExecution("Test", null, DEFAULT, steps, ORDER_SEND_DOWNSTREAM);

            // WHEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Iterator<org.neo4j.helpers.collection.Pair<Step<?>,float>> ordered = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator();
            IEnumerator <Pair <Step <object>, float> > ordered = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator();

            // THEN
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> slowest = ordered.next();
            Pair <Step <object>, float> slowest = ordered.next();

            assertEquals(3f, slowest.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> slower = ordered.next();
            Pair <Step <object>, float> slower = ordered.next();

            assertEquals(2f, slower.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> slow = ordered.next();
            Pair <Step <object>, float> slow = ordered.next();

            assertEquals(1f, slow.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> alsoSlow = ordered.next();
            Pair <Step <object>, float> alsoSlow = ordered.next();

            assertEquals(1f, alsoSlow.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(ordered.hasNext());
        }
示例#4
0
        private int CountActiveProcessors(StageExecution execution)
        {
            float processors = 0;

            if (execution.StillExecuting())
            {
                long highestAverage = Avg(execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next().first());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
                foreach (Step <object> step in execution.Steps())
                {
                    // Calculate how active each step is so that a step that is very cheap
                    // and idles a lot counts for less than 1 processor, so that bottlenecks can
                    // "steal" some of its processing power.
                    long  avg    = avg(step);
                    float factor = ( float )avg / ( float )highestAverage;
                    processors += factor * step.Processors(0);
                }
            }
            return(( int )Math.Round(processors, MidpointRounding.AwayFromZero));
        }
示例#5
0
        private void AssignProcessorsToPotentialBottleNeck(StageExecution execution, int permits)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> bottleNeck = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator().next();
            Pair <Step <object>, float> bottleNeck = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> bottleNeckStep = bottleNeck.first();
            Step <object> bottleNeckStep = bottleNeck.First();
            long          doneBatches    = Batches(bottleNeckStep);

            if (bottleNeck.Other() > 1.0f && BatchesPassedSinceLastChange(bottleNeckStep, doneBatches) >= _config.movingAverageSize())
            {
                // Assign 1/10th of the remaining permits. This will have processors being assigned more
                // aggressively in the beginning of the run
                int optimalProcessorIncrement = min(max(1, ( int )bottleNeck.Other() - 1), permits);
                int before = bottleNeckStep.Processors(0);
                int after  = bottleNeckStep.Processors(max(optimalProcessorIncrement, permits / 10));
                if (after > before)
                {
                    _lastChangedProcessors[bottleNeckStep] = doneBatches;
                }
            }
        }