Showing posts with label tinkering. Show all posts
Showing posts with label tinkering. Show all posts

Saturday, 9 November 2019

How did I halve my Build speeds?... Oh

Deconstructing my build hive... As you may tell form earlier posts this month, I'm on a mission to sort out some of my equipment and either recycle it or whatever, and on this mission one of the first stops has been the older dual socket servers, which live in the garage on an ethernet spur at the moment.

And, I've taken them down, now I didn't really appreciate how much they lent to my build times, as my main app server (on which I coordinate the building of gcc projects with distcc) started to report 4x longer builds (on average) and I couldn't find a reason for it.

I looked at the app server, I looked at the jobs being thrown about and really there was no reason for the massive slow down...

Until I remembered something about my VDI set up, the app server used two sources for it's virtual disk images, one local and one was passed over to the containers on the garage servers, these images could be mounted over NFS but more regularly I had the garage servers sync them and mount locally from their local disks.

In migrating the build containers back locally to the app server, I'd moved the containers from their local loop mounted VDI's to ones hosted on the app server... From being mounted from 15,000 RPM SAS disks at about 12gb/s to a SATA 7,200 RPM disk at 6gb/s.

I'd essentially halved the disk speed of my builds, and totally forgot about setting this all up, now I did this years ago, it must be about two years since I set it up and it's been nearly a year since I moved house and started everything back up on the ethernet spur, which necessitated using the copy/sync and local mount option to get over the slow 10mbs ethernet in the garage.

My plan therefore is to get the new power supply, experiment with the supermicroo motherboard and then see if I can set up a new ZFS based file server on that SAS controller... Watch this space.

Tuesday, 12 July 2016

Software Engineering : Arduino Uno - Flashing Clock

What is this flashing clock?  Well, it's just an arduino uno, with three LED's, one each for the seconds, minutes and hours.  They don't show the time, they just flash as each period they're counting passes.

So, we're going to count the seconds and flash just the second LED.  Then each 60th flash, we reset the seconds counter, increment the minute counter and have the minute LED flash.  Ditto for the hour counter each 60th minute.

I've got the LED's VCC legs connected to digital pins 8, 9 and 10, with the other connected to the three grounds.  When I come to make this an actual board I can have a single ground pin being used up, rather then using all three on the board.

An important part of the code to focus on is how to turn on each light in turn...

If you want to turn on the second, the minute and the hour LED all at the same time, you could have some horrid "if" statement controlling them, but much more clean looking is this:

// Turn lights on
switch(CycleCount)
{
    case 2:  digitalWrite(HourPin, HIGH);
    case 1:  digitalWrite(MinutePin, HIGH);
    case 0:  digitalWrite(SecondPin, HIGH);
                break;
}

So, the count is reset to zero each cycle it is incremented if we add to the minutes, and incremented if we add to the hours.

The switch statement then drops through, notice that there are no "breaks" on the 2 and 1 (hours & minutes) cases.  So, if we have incremented the hour, we have a count of two and so we set the HourPin High, drop through to the MinutePin High and finally the Second Pin High before we break.

Likewise, if we only set the minutes this cycle, then the count will be one, so the switch statement will drop down to the Minute Pin high, skipping the Hour pin totally.

The effect of this is to seemingly instantly turn on all the LED's each cycle as they are needed together, there is no humanly noticeable staggering of the lights coming on, as one might get with an if statement, or once might get if one were to set the LED as we increment the values.  Doing Lights on when we increment actually clearly shows the LED's going on and off in a staggered pattern.

Our task after turning all of them on is to just wait a short time (100 milliseconds) and then turn them all off with another switch statement.  And with them all off again simply wait for the remainder of the second (i.e. 900 ms).


Keep this in mind as you read the following code:

// The pins
int SecondPin = 8;
int MinutePin = 9;
int HourPin = 10;

// The counts
int CycleCount = 0;
int SecondCount = 0;
int MinuteCount = 0;
int HourCount = 0;

void setup() 
{ 
  // Setup the pins
  pinMode (SecondPin, OUTPUT);
  pinMode (MinutePin, OUTPUT);
  pinMode (HourPin, OUTPUT);
}

void loop() 
{
  // Increment the counts
  CycleCount = 0;
  SecondCount = SecondCount + 1;
  if ( SecondCount > 59 )
  {
      SecondCount = 0;
      ++MinuteCount;
      ++CycleCount;

      if ( MinuteCount > 59 )
      {
        ++CycleCount;
        MinuteCount = 0;
        ++HourCount;

        if ( HourCount > 23 )
        {
          HourCount = 0;
        }
      }
  }

  // Turn lights on
  switch(CycleCount)
  {
    case 2:
      digitalWrite(HourPin, HIGH);
    case 1:
      digitalWrite(MinutePin, HIGH);
    case 0:
      digitalWrite(SecondPin, HIGH);
      break;
  }   

  // Light are on for 1/10 of a second
  delay(100);

  // Tuen lights off
  switch(CycleCount)
  {
    case 2:
      digitalWrite(HourPin, LOW);
    case 1:
      digitalWrite(MinutePin, LOW);
    case 0:
      digitalWrite(SecondPin, LOW);
      break;
  }   

  // Lights all off for 9/10 of a second
  delay (900);
}

If you found anything of use here, please return again, and don't forget to check out my other YouTube videos.

Friday, 8 January 2016

Happy New Year 2016

So it's eight days into the New Year, and I haven't posted yet!... Oh well, here I am now...

I've nothing to report yet, I'm busy building some kit



Yes, that is a Chinese Arduino Uno clone... Costing £2.39... And it works a treat!


And I've been playing WarThunder....

And I've been cooking home made pizza....


My stories of what happened over Christmas, I'll have to get back to you later about.