Tuesday, 14 June 2016

Telex - and me

A Model 7 machine with its operator, 1959
Before email, before fax, there was a way of sending written messages reliably and securely between distant offices. It was called Telex. It worked much like the telephone, there were numbers and exchanges (central offices), and you called whoever you wanted, anywhere in the world, to send them a message. Instead of a telephone, you had a teleprinter. As you typed, your message would appear by magic on the distant machine also. You could even hold a conversation, taking it in turn to type messages to each other on the same connection. The Telex network was at the heart of banking, shipping, trucking, insurance and many other industries.

The teleprinter was independently invented by several organisations in the early 1920s. Originally they were connected together in pairs, one at head office and one in a branch. The limitations of this are obvious, and a switched network allowing anyone to talk to anyone else was an obvious next step. The first public Telex network in the world opened in Germany in 1933. It really prospered in the 1950s. Only recently, with first fax, then various computer network technologies, has it been eclipsed. The UK network closed in 2008.

When I was 16, like all students I wanted to earn some money during the school holidays. I could type well, thanks to the typewriters my mother had at home when I was small. One summer I worked as a typist, but my mother's advice was that there was more money to be made as a Telex operator. Back then this was considered a special skill - a company wouldn't expect a normal typist or secretary to be capable of it. Telephonists were just the same, even a small office would have a dedicated telephone operator at the company switchboard. When I started work at DEC in 1974, we had three of them for an office of maybe 200 people.

There were agencies that specialised in this kind of staff. I chose one called "Three T's" - for telephone, telex and... no idea, probably not telegraph though. I got in touch with them, and went along for an interview.

My mother's office had a Telex - though no operator since my mother took care of it herself. Even the boss knew how to work the machine there. It would have been smart to have spent a couple of hours using it before I went for the interview. But I didn't. So when they sat me down in front of their brand new Post Office Model 15 Telex machine, it was quite literally the first time I'd ever set eyes on one. This wasn't really very smart, but using my mother's description of how it worked I was able to figure it out in real time sitting in front of the machine. I even got complimented on how well I knew the machine!

So that was it, my career as a telex operator was launched. The next day I was working at one of the big investment banks somewhere in the City. They were a real heavy duty Telex user, with a bank of half a dozen machines, and operators to match. Some of the machines were used for live traffic, while others were used to prepare and verify messages on paper tape. Each message was a financial transaction, sometimes involving truly vast amounts of money, so a lot of attention was paid to getting it right.

All of the permanent staff were female. This was nearly always the case, though occasionally I'd come across an ex-military guy especially in the banks. A lot of the ladies had been trained during World War II, so by now were of a certain age. At one place I overheard two of them grumbling about the new generation of machines: "Oh, they're trying to make it so any old typist can use a Telex, well we know that's not possible, it needs special training, that's what it needs." And so on and so on.

The WWII era machines did require a bit of special understanding. There were still quite a few of them around in 1969, though they were disappearing. They were originally designed in 1931. They had a hammer green enamel finish and a very stark external design, with no concession to aesthetics. Under the cover was a massive electric motor and equally substantial mechanical parts, whose job was to convert faint electrical pulses into the position of a typewheel.

Keystrokes were converted to the Baudot Code for transmission. This has only five bits per character. By the time necessary control characters like line-feed are included, there are only 26 possible characters - not entirely coincidentally, the number of letters in the alphabet. To include numerals and punctuation required shift characters. If you pressed the key marked with W and 2, what actually got printed (both locally and remotely) depended on whether you had last pressed the letter-shift or figure-shift key. The operator had to remember this. She (usually) also had to pace the typing speed exactly to the mechanics of the machine. If you tried to type too fast, letters went missing. But if you went too slowly, you wasted time and on the Telex network, time was very much money.

There was another version of the same machine that had a paper tape reader and punch, so you could prepare your message without connecting, check it for accuracy, and then send it at the full speed of the network (about 7 characters/second).

A collection of Model 15 machines
The newer machines, called the Model 15, were much more modern, with a smooth grey finish and black plastic keys. They all had paper tape readers and punches. They had a four-row keyboard, like a typewriter. You still had to select letter or figure shift, as appropriate, but the inapplicable keys were physically blocked, so you wouldn't end up sending gibberish. I'm not sure that a regular typist could use one without a bit of training, but they were a lot less daunting than the old green ones.

Both types had a separate box for managing the connection to the Telex network. This had a dial, and several buttons to do the equivalent of picking up the phone and hanging up. It was a good size, well over a foot long and weighing about 15 kilos. Inside it was packed with relays and other signalling equipment.

One of the great advantages of Telex was security. When you made a connection, you could send a special code called "who are you" (or WRU) which triggered a mechanism in the remote machine to send a unique preconfigured response, called the "answerback". You could also send your own, by pressing a key marked "here is". Once you'd been through this exchange, each end knew with certainty who it was talking to. Hence Telex could be safely used for large financial transactions and other expensive commitments like sending a giant container ship to the other side of the world.

A Model 7 with paper tape, revealing its insides and showing
 the easily-blocked "here-is" key just above the keyboard,
slightly to the left.
At least, that's what everyone believed. The truth is, if you knew what you were doing, it wasn't secure at all. It was very easy to defeat the answerback mechanism. On the Model 7, all you needed was a pencil. When the machine received the WRU signal, the Here-Is key, perched awkwardly above the keyboard, dropped down to start sending the signal. If you wedged a pencil under it, you were then free to type whatever you wanted. On the Model 15 it took a little more mechanical ingenuity, but it could certainly be done, a very tiny adjustment inside the cover which could as quickly be restored. Whether anyone took advantage of this to commit fraud, I have no idea (honest).

How did I know about this? Whereas the banks ran their Telex machines flat out, there were several places I worked where there was hardly any traffic. One in particular was a timber merchant somewhere in East London, maybe Hackney. I doubt that there were even half a dozen messages a day. No doubt for security, the machine and its operator were in a closed, windowless office. There was plenty of time for a mechanically curious youngster, fascinated by how these machines worked, to investigate. It was at this place that I stripped a Model 7 down to its component assemblies, discovering all its inner secrets. I'm sure this was a serious infringement of the Post Office regulations, but if anyone had asked I would have said it had jammed and I just happened to know how to unjam it. Nobody would have been any the wiser. Luckily no messages tried to come in while I had the machine in pieces.

Some banks had their own dedicated international circuits. I worked at one that had its own dedicated circuit to New York, which must have cost a fortune. But to save money, it had some electromechanical trickery that meant it ran at a quarter of the normal speed. The Post Office sold the other three quarters of the circuit to other customers. It was odd to watch it ticking away in slow motion. What was really impressive though was one of the operators - unusually, a man - who could type at exactly the right speed, just less than two characters per second, to match the line speed. This being the 1960s, he did it with a lit cigarette hanging out of the corner of his mouth.

I did the Telex gig for a couple of summers, as well as some of the shorter holidays. I never told the agency that the first time I ever saw a Telex machine was when I walked into their office. But it didn't seem to matter, because for years afterwards, long after I had my degree and was working as a software engineer for far more money than 3Ts could ever hope to pay, they would get in touch with me every summer and ask whether by any chance I was free to go and replace a holidaying Telex operator.

Tuesday, 7 June 2016

The Rag Trade

After the War (which is to say in 1945), my Dad got a job in a London shop selling "trimmings". It sounds like something unsavoury from the butchery trade, but actually it means everything used in making clothes except the cloth - cotton, buttons, zips, elastic, linings and interlinings, and a host of other things most people don't even realise exist. For fifteen years he would take the train to London in the morning, to the shop on Old Street just north of the City and close to the sweatshops of Islington and Hoxton.

Then when I was about eight, he returned from our ritual week's holiday with my grandmother in Dovercourt to be told, "Sorry Reg, business isn't good, I'm going to have to let you go." And that was that, no employment protection then. Luckily my mother worked, part-time, but we had a typical working class hand-to-mouth existence and this was a disaster.

My Dad had few really sellable skills, so finding another job wasn't easy. Like nearly all of his generation he left school at 14. After a few false starts, he was lucky to find someone else in the same business who was willing to pay for him to learn to drive, for a job as a combined salesman and delivery driver.

The firm had the very British name of "Shepperton's". But the owners were actually a Jewish couple called Ettinger, refugees from Eastern Europe in the 1930s. Why Shepperton? They'd seen it on a map somewhere and thought it would be better than a Jewish name, in the bigotted English society of the 1950s. Though I'm not sure why, because practically all of their customers were Jewish too - the clothing trade, or "rag trade" as the insiders called it, was entirely Jewish then.

Soon my Dad had a bright orange Minivan to drive home every night. The routine was simple: bring the van home at night full of that day's orders, drive up to London the following morning dropping the orders off to all the customers in Essex and East London, while taking orders for the next day. He would arrive at Shepperton's in time for a late lunch, then drive round the West End taking orders and making deliveries until 4 or so, when it was time to stock up for the drive home.

The van was a blaze of colour. The sides of all their delivery vans were covered in the logos of the products they sold, long-forgotten names like Lightning Zips - sadly, I'm sure there is no picture anywhere. It took a skilled signwriter several days to prepare each one. My Dad had a deal that as long as he paid for petrol, he could use the van at evenings and weekends - which was good, because we certainly couldn't afford a family car. We had many outings in that and later vans, my brother and I sprawled awkwardly in the flat load space at the back. One early trip I remember was to a farm in the depths of the Essex countryside to get my first and only hamster, Nibs. (I have no idea why I wanted a hamster. I don't think he lasted long).

When I was a teenager, he would sometimes take me along for the day during the school holidays. So it was that I got see his daily routine.

The first call was close to our house, at the end of a muddy track by the railway line. Then we would proceed, never more than two or three miles at a time, stopping at one little clothing factory after another. Everywhere my Dad was welcomed like family, offered cups of tea, taken into back rooms to meet someone new. He was a natural salesman, it's just a shame he never sold anything you could really make money from!

He was a natural raconteur and a brilliant stand-up comedian, though the only time he did that was if we went to that uniquely British institution, the holiday camp, for our summer holidays. He had a huge collection of jokes, which he was always happy to trade for new ones with his customers. These were all Jewish, who seem to be the biggest fans of gently self-deprecatory Jewish jokes, so his collection of those was especially vast. The factories were tiny - the biggest ones had maybe 20 or 30 employees. They have all long since disappeared, replaced by giant sweatshops in Vietnam and Bangladesh.

One of his daily treats was a slice of toast and butter with a cup of strong British tea. He had an exclusive selection of cafes in East London, chosen for the quality of their bread (it had to be the real thing, cut in thick slices from an actual loaf - and under no circumstances sliced bread), the generosity of their butter, and the strength of their tea.  I still remember stopping at one of these places for elevenses, and the sensation of the melting butter oozing from the toast into my mouth. Strong, sweet tea, on the other hand, has never really been my thing. But then I didn't live through the Second World War.

Eventually we would get to Shepperton's, just in time for a late lunch. They had a shop (though you couldn't just go in and buy stuff) on Hampstead Road, close to Euston Station. It's an area that has changed beyond all recognition. There is no trace of Shepperton's, nor of Pat's, the seriously greasy  spoon cafe next door - of which more in a moment. A few steps away was Laurence Corner, the famous military surplus store where, supposedly, the Beatles got the inspiration for the uniforms on the cover of Sergeant Pepper's. The shop itself was barely-organised chaos, with packages of zips and buttons all over the place.

First stop was Pat's Cafe for lunch, something seriously greasy like sausages, bacon, fried eggs, and fried bread dripping with grease. My Dad was never overweight until long after he retired, but I have no idea how, considering everything he ate while he was working. He was (again) a much favoured customer, and would always disappear into the kitchen for a long chat with the eponymous Pat and the kitchen staff. The other staff at Shepperton's complained that after lunch, he smelled so much of kitchen fat that they couldn't go near him.

The afternoon was very different, driving round the West End and the more squalid areas to the north like Camden Town and Kilburn - this was long before gentrification had been invented. I was fascinated by the London bus system so I was very happy to sit in the van while my Dad exchanged jokes with his friends inside, jotting down the buses I'd seen and their destinations in my little red notebook. (I wonder whatever happened to those notebooks?)

Sometimes I'd go inside with him. I remember one place where they made fabric-covered buttons. A dressmaker would order a gross of buttons for a particular design. Everything was done in dozens and gross - a dozen dozen  or 144 - and occasionally a great gross, a dozen gross or 1728. Never 10, 100 or 1000. He'd supply the fabric and specify the size, and this tiny specialized place would assemble the buttons out of metal blanks. I was allowed to make one myself, cutting the material carefully to size, placing all the components in the press, then trimming the edges to make a neat fabric-covered button. I was very proud of my button and kept it for a long time.

Around 4, we'd go back to HQ to load up the van for the morning's deliveries. There's only one person there I remember, the first openly gay person I ever met. He was called Derek. He made sure you could not miss him. It was still illegal in Britain until 1967, so this was either just before or just after. Either way it didn't seem to bother anyone.

Then, the van loaded up with long rolls of interlining (the stiff material that goes between the dress fabric and the lining, to give shape and rigidity), boxes of buttons and zips, and various other odds and ends, it was time to set off home. The orange minivan didn't last long, and my memories are mostly of a series of vans based on the Ford 105E Anglia (the one with the odd sloping-backwards rear window). These were bought to the absolute minimum spec. They didn't have a heater, and they didn't even have a passenger seat. The passenger (me, in this case) sat on the ledge at the front of the load-space, with no back support and absolutely no security. It is unimaginable nowadays.

My Dad has his private route across London, eventually joining the A12 out to Romford. At the time I never understood it, but three decades later when I bought my flat in London I recreated a very similar route, which by using obscure back streets shaves probably 30 minutes off the time it takes to get from Kensington to Leytonstone. Once we reached the "arterial road" (the name given to it when it was built in the 1930s, as an example of high-tech high-speed road design at its finest), we trundled along at a stately 50 mph, close the maximum speed for these minimally-engined vans.

We would arrive home in Romford at about 6.30, in plenty of time for dinner. Strangely, when my Dad was on his own, he'd get home an hour or so later. That corresponded to the time he spent in the bookmaker's, picking up his winnings from the horses (if any) and no doubt sharing jokes with his mates there.

Monday, 6 June 2016

Just Popping out for the Paraffin

...and other excuses from a just barely dissolute life.


My Dad was as close to a blameless existence as any human being ever can be. He didn't drink, except an occasional half of cider in the summer. He didn't have a shred of violence in him, and he certainly wasn't a womanizer. He smoked, but so did everybody then. He had just one small vice: the horses. Every Saturday he would study the form, place a few bets, watch the races on the television in the afternoon, and if he got lucky, he'd go and collect his winnings.

We lived very close to our local shops. It was only a two minute walk, and the bookmaker's (the bookie, or "Ernie's") was one of the closest. It was nothing to pop over there three or four times during the course of the day, as necessary. There was just one problem: my mother. She absolutely did not approve of him betting on the horses, though heaven knows it was a small enough vice and his bets were tiny - generally a shilling (£0.05) each.

So he couldn't just say, "I'm just popping over to Ernie's, back in fifteen minutes," and get the reply, "OK, see you soon". Instead he had to make a just-barely-plausible excuse.

Our house, like all English houses of its vintage, had no central heating. There was a coal fire, latterly replaced by a gas fire, for the living room. The kitchen was supposed to be kept warm by cooking, and in the bedrooms... you were supposed to be in bed anyway. I remember scraping ice from the inside of the windows during the winter. So in the kitchen and the bathroom, we had portable paraffin heaters. The ones we had were cylindrical, a couple of feet high and about a foot across, with a tank holding a gallon or so of fuel at the bottom. They needed constant adjustment and frequent maintenance, but no matter what you did, they stank. The very first thing to do on getting up on a winter's morning was to light the heater. By breakfast time the room would be just barely warm, and filled with a miasma of fumes and unburned paraffin.

For those who've never seen it, paraffin is a clear, greasy inflammable oil, a bit like diesel. Back then every house and workshop had paraffin heaters, and every hardware store had a big tank of the stuff, which they would sell by the gallon. To keep our heaters running, it was a weekly chore to go round with a five-gallon plastic container, returning with it filled. I occasionally did it myself, as a teenager, and I remember the weight lugging it home - 42 pounds, or about 18 kg, if my arithmetic is right (it weighs the same as jet fuel - these were English gallons, remember).

One of my Dad's excuses was this regular excursion, just before lunch, when he would place his bets. "I'm just popping out for the paraffin," he'd say, and he'd walk off up the three steps to the street, wrapped up tight against the chilly winter weather, the empty paraffin can in his hand.

The trip to the hardware store, waiting to be served, and coming home again, took about a ten or fifteen minutes. At least it did when I did it. My Dad took an hour or more, because, of course, most of the time was spent at Ernie's. I think it was as much a social occasion as anything else. He was a very social man, especially with people he knew but not all that well. He was a salesman by trade, and I think quite good at it although there wasn't much money to be made selling haberdashery.

That was the second trip of the day. The first, just after breakfast, was announced as "I'm just going to pay the papers." Like everyone back then, we had a newspaper delivered every day - the Daily Express, a favourite of the right-leaning working class. On Sundays there was the Sunday Express and - naturally - the News of the World, a titillating scandal sheet and favourite of the working classes right up to its own scandalous end a few years back, and the home of the phrase "then I made an excuse and left."

The papers were supplied on credit, and once a week there was a visit to the local newsagent (actually we had three) to stand in a long line of people waiting to pay their account. It was another fifteen minute round trip, which took my Dad an hour. I think his first trip was to study the form.

The afternoon was spent watching the races. I can still remember the noise and rhythm of the commentary, the stock phrases like "and now - now he's coming up on the inside! - and it's Bright Blaze, Bright Blaze by just a short head". Actually I hated it, and would hide away in the kitchen or my bedroom while it was going on, but like the football results later in the afternoon it was an inescapable part of every single Saturday. After the races there just might be some winnings to collect. In that case there would be some other domestic excuse for an outing - some cleaning product that needed to be replenished from the supermarket round the corner, another five minute trip that would take an hour.

Of course my mother knew perfectly well what was going on. In later years I learned that it annoyed her intensely, though I'm not really sure that honesty would have been any better a policy.

It wasn't only on Saturdays that things took longer than they needed. My Dad had a job that combined selling with delivering the things that he'd sold, and every evening he would drive a little delivery van home from the firm's base in the West End, full of odds and ends to be transformed into clothing in the sweatshops of East London. Occasionally in the school holidays he would take me with him. We'd leave just after five, and be home by 6.30 or so. Yet when my Dad was on his own he was never home until 7.30, an hour later. It's not hard to guess where the time went.

It was a blameless life, but still it needed a supply of excuses.

Wednesday, 11 May 2016

Grisou RIP

Grisou at his most felinely handsome. He always looked a bit of a rogue.
Our beloved Grisou is no longer with us. He went for his evening stroll around 7 on Sunday evening, and didn't come back. The following evening we heard that he'd been hit by a car on a busy road a long way from the house, far further than we ever thought he roamed, where we found his poor dead body.

Grisou's first day at our house
He was just barely a year old. By an awful coincidence, he was almost exactly the same age as Missy's brother Hercule was when he was also killed by a car, three years ago - thirteen months and a few days. He'd been with us less than a year, we were looking forward to celebrating the anniversary of his arrival on 21st May. That will never happen.

Poor Grisou. Poor, poor Grisou. He was a cat with an incredible character. His morning and evening strolls took him round our whole neighbourhood - and much further than we ever thought. Everyone knew him, he was a regular visitor to every garden.

But let's start at the beginning. After Hercule died, it seemed a good idea to get a second cat to keep Missy company. Whether cats need or want company is a big unknown, though she seemed very happy to be with Grisou once they got used to each other.

A good idea, but we worried how Missy would react at first. She is a very timid cat - unlike Grisou, probably no more than a couple of our neighbours even know she exists. As a result, it took us two years to act on the idea.

Isabelle saw a litter of kittens in the window of our local vet's office. Four were black, and two were grey. We went and held them, tiny tiny kittens that fit in the palm of my hand. We chose Grisou, rather than the other grey one, because even at just a few weeks old he seemed to have more character. He was tiny, about 800 grams (1.5 pounds), and liked to stand on my shoulder. For the first few days he hadn't quite mastered his hind legs, when he jumped he would land on his forepaws then not know what to do with the rest, landing in a tangled heap. He soon figured that out though.

The introduction to Missy was very tricky and painful. We kept Grisou in our spare bedroom, but he was desperate to escape - it was a challenge to open the door without him zooming down the corridor into the rest of the house. Missy knew he was there and would sniff at the door, miaowing. Our house has an enclosed atrium, open to the sky but not to the outside world. We would put Grisou in there and let Missy see him. Even though he was just a tiny kitten, she was frightened of him. She would stare at him for a minute or two, then retreat to the garden with her ears flattened.

Why Grisou? It's a French word, though nothing to do with cats - it means "firedamp" (methane) - but "gris" means grey. And it rhymes with "bizou", meaning kiss. He was a uniform medium grey all over, from his nose to his tail, with just very faint bands on his tail. His actual nose was a different shade of grey, which seemed to change all the time. He was beautiful.

Missy became more and more reluctant to enter the house at all until finally one morning I realised she hadn't even been inside to eat. I rushed to put her food outside and she ate with enthusiasm. She continued to eat outside for about three months. Very gradually she started to come back indoors, and to allow Grisou to get closer to her. He was full of enthusiasm and would chase after her, until eventually she would jump onto the fence leaving Grisou on the ground puzzled, thinking "How on earth did she do that?"

Eventually they settled down to a sort of clawed truce. They would play fight and hiss (well, Missy hissed) and chase each other around the garden or the house, but they never hurt each other (though Grisou would often have a bit of Missy's long fur stuck in his teeth). Then they'd settle down and snooze close enough to touch each other.

As soon as Grisou was big enough to go out, he started roaming the whole neighbourhood. He was a true "people's cat". We were shocked when, chatting with a group of our neighbours, we discovered they all knew him as a friend, a regular visitor to their gardens. We often saw him crossing our street, or just sitting at the side of the road - fortunately it's a very quiet street and nobody drives fast. One day we caught him teasing a dog who has a rather poor history with cats - an extremely bad idea, even though the dog was soundly tied to a tree. That was when I said, "It'll be a miracle if he lives to his first birthday." Well, he did, but only just, and not to his first anniversary with us.

Late last summer, we started keeping them both indoors at night. Partly this was just for my own sleep and sanity, since if I woke up in the night and one cat wasn't there I wouldn't be able to sleep. And also there were coyotes in the area, attacking and eating pet cats. It worked very well all through the winter. Both cats would be indoors by 8pm or so, we'd close the catflap, and have the security of knowing they were safe with us. They didn't seem to mind.

As the days got longer in spring, though, it got harder, and Grisou often wouldn't come home until bedtime. We knew he was touring the neighbourhood, though we had no idea how far we went. The furthest I ever saw him was half way to the main road - about 300 feet from the house. I really hoped that was the furthest he went - little did I know.

Whenever we travelled, we had a friend come by twice a day to feed Grisou and Missy and give them a cuddle. At first we wanted them to be indoors the whole time. We left the cat flap in its "entrance only" position, in case one got out by mistake. Then we had reports that they were both in the garden. We didn't know how until our friend saw Grisou lay on his back under the door, stick a claw into the plastic frame and pull it open inwards, then squirm out from underneath. We realised it was hopeless, so when we were away they had the freedom to come and go as they pleased.

We were away for a couple of weeks in March and April. After we got back, Grisou was out until the small hours a couple of times. He was quite a creature of habit. He would snooze indoors or close to the house all day, usually on his favourite footstool in our living room (where now there is nothing but a desperately sad cat-free space). Around 5 he'd start grooming, by 6 he'd be outside, and around 7 he'd disappear for the rest of the evening. Usually he came back before bedtime for a snack, and we'd close the cat flap. Then one morning recently we found that he'd figured out how to open it! He'd moved the heavy carton from in front of it then, most surprising, moved the stiff plastic catch that held it shut, opened it and escaped. I caught him trying to do the same thing late one night, after he'd popped in for a quick snack, so I put some heavy furniture in front of it. He was furious and spent the next hour complaining loudly. He almost never miaowed, only when he was cross. The following night, he simply didn't come in at all until about 3am.

Usually, he eventually accepted being shut in, and then he would settle down for an initial nap at the very back of a closet in our bedroom, almost completely invisible. At some point in the small hours he and Missy would have a ritual exchange of views, and then he'd settle down in his second night snoozing spot, on a cushion under some furniture by a window. He'd stay there often until 10am or later. Then he'd go out for his morning stroll, until 12 or so when he'd settle on the footstool for his daytime snooze again.

Sometimes he'd have a snooze at the top of the cat tree we got when Missy and Hercule were kittens. He'd leap to the top, his six kilos (13 pounds) very nearly toppling the whole thing, then curl up in the small space there. He never quite fitted, there was always a paw dangling out and his tail.

A few days before his birthday we had some sushi and gave him some of the tuna. He loved it. So his birthday treat was some sashimi-grade tuna from the Japanese supermarket. He loved that even more. His normal daily diet was dry cat food, with an evening treat of tinned tuna, and a morning treat of wet cat food. Missy too, though as far as we can tell she mostly only eats the dry food.

Some books say you should give your cats separate feeding places. So we did, we set up one in each of two bathrooms. The theory - our theory - was that one was for Missy and the other for Grisou. But they didn't take that seriously. For the last few days he was alive, they both ate "chez Missy la chatte", cleaning it out every night, while Grisou's place remained untouched.

Missy and Grisou in their respective snoozing places
A few days ago I came home early from work. It was so nice sitting in the garden in the evening sunshine with two cats, sometimes sitting quietly, sometimes chasing each other crazily around the garden, from one end to the other and back again. On Saturday afternoon I sat in my armchair, Grisou snoozing on the footstool and Missy on her favourite dining chair, both within reach. It was soporific, I wrote "There are few things less inducing to getting on and doing things than sitting between two snoozing cats". Perhaps I shouldn't have tempted fate.

Last Sunday, Isabelle returned from a trip to Europe. Both cats were waiting for her when we returned from the airport. Grisou seemed really happy to see her, demanding a cuddle and following her round the garden. Then in the evening he went off for his usual tour. The last time I saw him - alive - I remember he was licking delicately between the toes of his hind paws. He was so beautiful, so supremely feline.

He didn't come home before bedtime. I woke up at four, still no Grisou. I didn't get back to sleep. At 6 I looked everywhere for him, driving round all the local small streets. At lunchtime we put flyers in nearly 100 letterboxes, including places we thought were far outside his range. We still hoped, of course, that he'd show up - maybe after being shut in somewhere, or maybe deciding to get food and shelter in one of his many adoptive homes. We were sure of one thing - we'd looked everywhere and not seen a body by the road.

But were wrong. In the evening I got a text in response to the flyer, from someone who had found him dead in the main road. She'd called the police who had moved his body to the median where we hadn't seen it. So we walked down there, and there was his poor dead body, intact. You could almost believe he was just sleeping. But he wasn't. He was dead. And that is final. We carried his poor body home, to touch him one last time.

We used to speak French with him. When he showed up we'd say "il y un Grisou" (there's a Grisou) or "on a un Grisou" (we've got a Grisou). And I still say it to myself. But now it's not true, and it never will be, never again. And my keyboard is wet with tears.

The last ever photo of Grisou, the day before he died

Tuesday, 3 May 2016

The Importance of Virtual Destructors

Our system had a memory leak. It wasn't huge, but network software (unlike phones or laptops) has to run for months or years without failure, so it was unacceptable. Unlike most complex software in C and C++, we are not plagued by memory leaks, so this was a bad surprise. We make extensive use of smart pointers (though not the horrible shared_pointer class, which is an ugly accident waiting to happen) and the RAII paradigm. As a result, objects get deleted when they should, whether they are short-term temporaries or long-term configuration information. Yet, we were leaking memory.

The fix, once we tracked it down, turned out to be the addition of a one-line function with an empty body:

virtual ~query_helper_iterator_base() { };

How can an empty function fix a complex memory leak? Read on...

Our system (STM) keeps track of several very large collections, of potentially millions of objects: network applications, hosts, users, network routes and several others. It provides a SQL-like Rest API that can be used to retrieve them based on complex filters and other criteria. For example, you can say "find the top 20 applications ordered by traffic rate, and tell me their current traffic rate and flow count".

Our web-based GUI maintains several charts, which it updates periodically every few seconds via the Rest API. Many users can run their own copy of the GUI, so these complex queries can be seen several times per second. The problem is that they require the whole collection to be scanned, and every entry to be inspected. As you may imagine, this is very expensive in CPU cycles and memory bandwidth, and we found it was a performance problem for our larger installations.

All of these collections are scanned in the background every few seconds, to maintain performance information. It doesn't seem hard, as we scan the whole collection and have them in L1 cache, to preload a cache for common queries such as the one above. Hence we came to write the query_helper collection of classes. Thus armed, we can say to a collection "do you have a cache which matches this query?". For example, we keep a cache of the top 1000 applications by traffic rate. When the GUI asks for the current top 20, we simply look at the cache and pick the top 20 from it - much easier than scanning a million applications.

Different caches have different implementations, depending on the nature of the query they are designed to support. For example, some use a simple STL vector, while others, which are explicitly ordered, use an STL set. This implementation detail needs to be hidden from the internal user, who merely knows that they have been given a cache that matches their query. This is, of course, an obvious application of virtual functions and pure base classes. The user sees a query_helper object, whose implementation is hidden behind them. So far, so straightforward.

The problem comes when we consider the iterators for these collections. The normal usage is a range-based for loop, which has to create a concrete iterator over the collection:

query_helper *qh = collection->find_matching_helper(rest_query);
if (qh) {
    for (object *obj : qh) {
        ...

The type of the iterator must be known, in detail, at compile time, yet the full type of the collection varies dynamically at runtime. How can this be made to work?

The solution is to use a second level of iterator, to which the base class iterator simply contains a pointer. That can in turn use virtual functions to implement an iterator in terms of the specific implementation of the actual query_helper object. The outer iterator simply delegates every function to the corresponding virtual function of the inner iterator. The only complication is that creating an iterator requires a dynamic memory allocation, but in the overall scheme of the Rest API implementation this is small stuff.

By now you're probably wondering what this has to do with our memory leak. I need to explain another implementation detail. The caches are rebuilt from scratch at every scan of the collection. But what happens if someone is using one when this happens? How can we know when it is safe to delete the old cache? The answer is that our cache uses our generic intrusive reference count mechanism. The object contains a reference count, and the same "mixin" class (called reference_countee) that provides it also provides a class-specific smart pointer that manipulates the counter, deleting the object when the count falls to zero.

So all we have to do is include said smart pointer in the iterator object, and it will protect the old cache from being deleted until the iterator is deleted. No possibility of dangling references, and all taken care of by C++'s constructor and destructor system. Nothing can go wrong...

Except (as you've guessed) something did go wrong. In fact, any cache that got used during its brief lifetime was never getting deleted. Reading the code, everything should have worked. The outer iterator (for the query_helper base class) has a destructor, which in turn deletes the inner iterator it points to The inner iterator's destructor destructs the smart pointer, which in the process decrements the reference count and, if this was the last user, deletes the object. That mechanism - the same identical C++ source code - is used in dozens of places in the code, and it works.

This, finally, is where the empty one line function comes in. C++, because of its heritage in C, doesn't assume that a function is virtual. Unless it's explicitly declared to be, the compiler assumes it can safely generate a static call to the member function of the actual class pointed to, rather than incurring he extra cost of using a function pointer. The base class of the inner iterator has no content, so the automatically-generated destructor does nothing.

So... when the outer iterator was deleted, its destructor was called. That correctly called the destructor for its contained inner iterator (thanks to std::auto_ptr... don't get me started on why the new unique_ptr is a terrible idea). But, instead of calling the proper destructor for the derived class, which would decrement the reference count and hence allow the old cache to finally be deleted, it was just calling the trivial destructor for the base class.

It's not the code in our one-line function that matters, it's simply the fact that it exists and (most important) is declared virtual. That tells the compiler that instead of generating a static call, it must look in the object's virtual function table (vtable) to find the corresponding function in the derived class.

C++11 purists will say, correctly, that there is another way this should be caught. If we define a function whose sole purpose is to override a virtual function in a base class, it should be given the 'override' qualifier. This would have generated a compiler error since the base class didn't in fact have such a function to override. We consider our wrists duly slapped, and will redouble our efforts to ensure that such functions are duly qualified.

This is pretty hard to understand, so at risk of making it even harder, here are some code snippets to illustrate what is going on. (It's not quite right yet - it's very hard to get the blog system to handle angle brackets).

/************************************************************************
 * First the base type for the INNER iterator - the one that MUST have
 * the critical virtual destructor. All its member functions, like
 * operator++ shown below, are pure virtual, and there are no member
 * variables.
 ************************************************************************/

class subtype_iterator_base : public std::forward_iterator_tag
{
public:
    // virtual ~subtype_iterator_base() { }; // the vital virtual destructor!
    virtual subtype_iterator_base &operator++() = 0;
    ....
};

/************************************************************************
 * Now the base query_helper class. This is the only class seen by the
 * users of this function - they are never aware of any of its derived
 * classes.
 ************************************************************************/

class query_helper
{
    ....    
/************************************************************************
 * Now the OUTER iterator of the base class. It contains only one member
 * variable, an auto_ptr to the base INNER iterator which actually does the 
 * work. All its member functions simply delegate to the corresponding
 * virtual member function of the inner iterator.
 ************************************************************************/

    class iterator : public std::forward_iterator_tag
    {
    private:
        auto_ptr my_sub_iter;
    public:
        iterator &operator++() { my_sub_iter->operator++(); return *this; };
        ....
    };
    ....
};

/************************************************************************
 * Finally, a specific derived class of the query_helper class, in this
 * implemented (somehow) using an STL set. It defines an iterator class,
 * derived from subtype_iterator_base, which in turn has a smart
 * reference-counting pointer to the query_helper it is using.
 * 
 * Note the inheritance from reference_countee (using CRTP), which provides
 * both the intrusive reference count and the ::pointer smart pointer
 * class. 
 ************************************************************************/

template<class OBJECT_CLASS, class COLLECTION_CLASS>
class query_helper_xxx : public query_helper,
                         public reference_countee<query_helper_xxx>
{
private:
    std::set<OBJECT_CLASS*> my_items;
public:
    class my_iterator_t : public subtype_iterator_base
    {
    private:
        typename std::set<OBJECT_CLASS>::iterator my_iterator;
        typename query_helper_xxx<OBJECT_CLASS,COLLECTION_CLASS> ::pointer 
            my_qh;
    public:
        C *operator*() const override { return *this->my_iter; };
        ....
    };
    ....
};

Monday, 2 May 2016

Flying the London Helicopter Routes

To small planes the whole of London, from Docklands in the east to beyond Heathrow in the west, is a no-go area. With Heathrow's airspace, and London City's, and restrictions over the centre of London, almost everything inside the M25, except for fringes to the north and south, is closed.

Helicopters, though, are a different story. Because of their ability to land engine-out in a very small space and without risking damage on the ground, they are permitted on a small number of carefully planned routes that provide an out along their entire length - mostly in open spaces, except for central London where it is the river. These routes allow you to fly all along the Thames, from Chiswick to Greenwich, as well as directly overhead Heathrow airport. Considering how protective the UK is, it is astonishing - but true - that you can fly over Heathrow in the tiniest of single-engine helicopters, the Robinson 22. But you can - there are even videos on Youtube.

I'd wanted to do this for a long time, and finally a trip to England provided the opportunity. I booked a Monday morning flight with EBG Helicopters at Redhill Aerodrome (EGKR), in one of their Robinson 44s, so my son could come along too. I'd previously flown there in their Guimbal Cabri G2 (G-ETWO - geddit?). That was a very interesting introduction to a new (to me) type, but we didn't go very far from the field.

I'd prepared for the flight by studying the helicopter route chart, available from Pooley's, and reading what I could find on the web, e.g. this. From the south, the most interesting routes are H9, which runs dead straight from the A3 to just south of Heathrow at Bedfont, and then north to the A40 at Northolt. That is followed by a stretch of H10, along the A40 then turning right onto the North Circular Road (A406) to the river. There is a lot of IFR - I Follow Roads (or Rivers) - involved in this. H10 joins up with H4 (via a short stretch of H3), snaking along above the Thames from Kew through the centre of London to the Isle of Dogs. South and east of there, you can do what you want, relatively speaking anyway. H7 provides an alternative route north from Redhill straight into H4 if you don't want to fly over Heathrow.

Over the weekend, the forecast was not good, and I was afraid I'd have to cancel. But the morning dawned with blue skies. It clouded over by the time of our flight but never worse than 2500 overcast, plenty for this trip.

The first challenge is finding the aerodrome. Redhill has to be the hardest to find in the whole world, despite being only a couple of miles from Gatwick and sandwiched in the corner of the M25 and the M23. I'd been there before so had a rough idea, but was still very grateful for the data roaming package on my phone as I followed a succession of single-track country lanes and narrow roads through housing estates.

Once you find it, Redhill is a very interesting place. It's home to many of London's helicopters, including the Surrey Police, an air ambulance, Sky's ENG ship, and a good selection of expensive-looking executive machines. It also has a couple of grass runways but I've never seen a fixed-wing operation there - I think the runways must be waterlogged a lot of the time.

Briefing for the flight was simple enough - no flight plan or other permission is required. A quick call to Heathrow's ATC confirmed that they were taking H9 transitions, and then we jumped into G-PAMY to start our adventure: me, my son Joe, and my instructor for the day. It would be crazy to try a flight like this for the first time without someone who has done it plenty of times before. I asked him to take care of the radio calls since there are plenty of unfamiliar visual reporting points, and I'm not 100% comfortable with the differences between UK and US radio practice.

After takeoff our first call, crossing the M25, was to Heathrow Special. This sounds an odd name, to me anyway. All non-airline flights in Heathrow's airspace are done under Special VFR (SVFR), which is essentially VFR flight under IFR-like control. I did this once before flying from White Waltham to Stapleford, though I never got anywhere close to the airport. Heathrow Special is a dedicated frequency for such flights. They cleared us as far as the Bedfont holding point, at "approved altitude".  Every segment has an approved maximum altitude on the chart, sometimes changing every couple of miles, and you are expected to have this information to hand.


Close to Bedfont we were handed off to Heathrow Tower - a first for me and, unless I do this again one day, the only time. They were very friendly and helpful, despite handling the two busiest runways in the world as well as a pesky helicopter. There had been some concern about how long we'd have to hold, one of the guys at Redhill mentioned holding for 20 minutes and then again for 15 minutes between the runways. We had plenty of fuel and the view is excellent, so it wouldn't have been a problem, but it didn't happen. We were instructed to wait for one landing aircraft, which we did hovering at 1000 feet just south of the 27L runway numbers. Joe got several excellent shots of the arriving Air Canada 767. Once it was on the ground we were cleared to proceed across both runways, having hovered for less than a minute. The view was absolutely spectacular, along the whole length of Heathrow. I'm using to flying past San Francisco, and have even landed at LAX, but this was really extraordinary. There was a long line of departing aircraft, with a BA Airbus 380 at the tail. In fact I counted 5 A380s on the ground - a significant proportion of the entire fleet.

Once north of the airport, we went back to talking to Heathrow Special as we admired the collection of bizjets at Northolt - no evidence there that it is still owned and operated by the RAF. Soon we reached the Thames at Kew. The river is surprisingly twisty and quite hard to follow accurately, even though I slowed down to 60 knots - partly for manoeuvrability but mainly to enjoy the view. And the view was fabulous. With Battersea heliport below to our right we could see right across London, with Chelsea and the Royal Albert Hall off to our left. (At home we joke that Albert is plane spotting from his memorial, writing down the tail numbers of the airliners on long final into Heathrow in his royal notebook - this was probably the first time he logged G-PAMY).


Further on we got a very special treat - our timing coincided exactly with the Changing of the Guard at Buckingham Palace, giving us a spectacle of the Household Cavalry as well as the massed tourists in front of the palace. From the same location we also got an excellent view of the Houses of Parliament, Big Ben, Westminster Abbey and then Whitehall and Downing Street. I once had the good fortune to attend a meeting inside No 10 (the Cabinet Room, no less, though the occasion was much less exotic), but I'd certainly never seen it from this angle.

By now we were talking to City Airport tower, and they had us hold just short of Tower Bridge. We had a tailwind so hovering wasn't a great idea - instead we made a tight turn over the river and returned to Westminster Bridge, giving us a magnificent second showing of central London. Sadly we only got one turn around the hold, before City cleared us to proceed overhead Tower Bridge, following the twists of the river until the exit point of H4 at the southern tip of the Isle of Dogs.

From here it was a simple straight flight back over Croydon to Redhill, with a glimpse along the way of the remains of Croydon Airport, London's main airport before the War. All that's left is the terminal, a pre-war airliner in front of it, and about 200 feet of the runway.

Back at Redhill I demonstrated an autorotation to Joe - the common belief is that helicopters drop out of the sky if the engine fails, but in fact a power-off landing in a helicopter is much safer than in a plane since you only need a very small space to touch down. The aircraft descends quickly, but under complete control, and at about 40 feet above the ground you flare to slow down and stop the descent, then drop gently to the ground, cushioning the final drop with the remaining energy in the rotor.

From there it was a short hover in a challenging crosswind back to EBG's base, and we said goodbye to G-PAMY. Though not to Redhill, since we stayed for lunch at the excellent airfield cafe. The food is very good, but the best part is the toilets - or rather the walk to get there, which takes you around three sides of a hangar filled with unusual and vintage aircraft, including the only remaining specimen of the 1932 Spartan Arrow.

It was a wonderful trip, so good in fact that I'm awfully tempted to do it again when I'm in England again! There are lots more pictures from the trip here.

Tuesday, 9 February 2016

Offroad in Anza Borrego: Coyote Canyon

The first part of our journey is here.



We arrived in Borrego Springs just in time to go to the visitor center there. By good luck we spoke to the same lady as a few years back, who has loads of offroad experience there and was very happy to give us updates about the state of all the trails. In fact the park even produces a frequently-updated summary of them. This is in sharp contrast to Death Valley, where all the visitor center will tell you is "we don't recommend the such-and-such trail" - so you're on your own to go try it, which I suppose isn't that bad.

We'd already read about many trails in the park in Backcountry Adventures: Southern California. This book, and its companions, are an incredible wealth of material - not only detailed descriptions of hundreds of trails, but masses of background information about the region, the wildlife, the people, and just about anything. There are plenty of trail guides (I have all of them!) - but these are the best.

Her advice was to start with the Coyote Trail, so we did. It leads to the north, starting past the huge orange groves, which seem out of place in the desert. At one time you could take it all the way through to the LA basin, but now there's a stretch in the middle which is closed making it into two in-and-out trails. At first it's an easy, sandy track, which we took on our first visit in an ordinary rental car, to walk up the amusingly-named Alcoholic Pass. The octotillos were just beginning to bloom. After a while the trail
crosses back and forth over a stream. Apparently it can get quite deep - I'd taken the precaution of noting exactly how deep I could  go (just up to the top of the wheel rims) - but after the dry winter it barely got FJ's tires wet.

The challenging part comes immediately after that, a steep, rocky stretch a few hundred yards long. FJ barely even noticed - I didn't even engage low gear - but it's certainly the end of the road for rental cars and regular SUVs. Once at the top, the view suddenly opens out into the huge expanse of the Collins Valley. It's one of those times when you are really glad to have FJ - there is absolutely no other way to get here other than a multi-day hike.

There is one main track through the valley, but many interconnected side trails so you can do a lot of exploring on wheels. We saw a few cars on the main trail, and a couple of parked vehicles at the trailheads, but we pretty much had the place to ourselves. Our favourite spot was Salvador Canyon, with a very luscious spring, and high up in the hillside, a cluster of palms just like the much more famous and much more visited Palm Canyon.



The last couple of miles of the valley are very rough, and we wondered whether it was worthwhile. Our doubts were removed at the end, at Middle Willows. A fence very definitely ends the drivable trail. We walked a little further upstream, in the direction that once led right through to Anza Canyon. The spring is very lush, completely hidden by dense vegetation. It's a beautiful place.

It was mid-afternoon by the time we returned. There was just time to explore the Truckhaven Trail. This is the original road from Borrego Springs to the Salton Sea, built in the 1920s by the local farmers who needed a way to get their produce out. Much of the time it goes through sandy washes, but even so it would be a challenge in a Model T or a primitive truck of the period. And from time to time it suddenly scales a canyon wall. The worst part is a recent bypass around a washout. From the description in the guide I wasn't sure I'd be able to manage this, but FJ barely noticed, chugging up the 30% grade at a walking pace. It's short but spectacular, leading over the top a ridge and then an equally steep grade back down into the next canyon.

That just left us time to get to Fonts' Point before sunset. This is a spectacular overlook which can, with care, be reached in a rental car (I know!). There is a panoramic 360 degree view, but the most intriguing part is right at your feet, the badlands, square miles of low hills and canyons made of dried mud. Each time I've been there I've wondered what it would be like to be down amongst them. This time, as I'll describe later, we had the means to find out.

That evening we went for dinner at the only "fine dining" restaurant in the area, the Butterfield Dining Room at the Casa del Zorro, a couple of miles outside the town. The food was good and so was the wine, and the service was friendly and unpretentious, which we always appreciate. The ambiance was rather spoiled, for me anyway, by what seemed to be a group of long-since retired salesmen, completely dominated by their ex-boss who was only too happy to share his old-fart, reactionary opinions on everything with the entire room. There times when it is an advantage not to be a native speaker!