Sunday, February 18, 2007

 

Senco Coffe Pod Machine - making darker coffee

Start the machine for 2 seconds then stop it. This allows the pod to soak in hot water. Let it soak for a minute or so, then start the machine as normal. Now the coffee should be much darker and stronger.

Friday, February 16, 2007

 

Mother - tell your children how to count my notes

Mother by Danzig sounds simple enough, but as soon as I started playing along with the song, I notice that I mess up the timing after a while. Mainly cause the song just a syncopated rhythm and it speeds up quite a bit as it goes along. The solution was to rewrite the rhythm in my head. I added a phantom note on the beat before the syncopated notes. This made it easier to sync my foot tapping with the song and I'm able to keep up with the live version on Demon Thrall minus the solo.

 

Virtual Channels vs Data Path

This caused me a little confusion early on, but now I don't know why. However, I know it's causing other people some confusion too. Data path is the physical path the data frames travel. The path is determined by the routing protocol.

Virtual channels are logical channels inside a data path. It's generally used as a throttling mechanism so a particular stream of traffic doesn't hog up more than its shared of the data path throughput. Virtual channel can be implemented with a credit model between peers. Also, each virtual channel generally has its own queue.

 

Got a Miata

I picked up a '96 Miata yesterday. It only had 36K on it and I had a mechanic to a quick check on it. I think I over paid a bit for it, but at this price range, that's not a big deal.

I haven't never own a manual transmission car before, so my experience is quite limited. I just realized today that I been skipping 3rd and 4th gear and going to 5th quite often. This causes a great bit grinding noise as the dog teeth try to engage. This is partly due to me driving at night and not realizing the damn car was a 5 speed instead of 4. I took a closer look at the stick this morning and realize my mistake.

Down shifting is still a pain, and I lock up the wheels quite often. I'm breaking the down shift into multiple steps for now. First, I step on the clutch and shift into neutral. Then I rev up about 2K RPM and down shift. However I only press the clutch once instead of twice. I need to find out if that causes any problems or not.

Here's some good information for heel-toe shifting:
http://www.edmunds.com/ownership/howto/articles/45792/article.html.

Monday, February 12, 2007

 

Dave's Run and the 5 O'clock Shadow

Dave's Run at Mammoth had moguls as large as a '66 VW Bug. Alright, I just pull that year out of my ass, as I'm sure there were moguls as large as a '72 Bug as well. On that first day I ski it, it happen to be 5 O'clock and it was my last run for the day. My legs already burning from hopping around the fresh snow on the back side. Dave's Run well exposed to the wind and it was quite bare. At 5 O'clock on this particular day, the sun is at the perfect angle such that it generated almost no shadows on these gigantic bumps. The invisible bumps pushed my knees into my chest over and over again, and I was too tired to push back down to gain traction and control. It was like an old Chevy with broken shocks coming down a dirt service road after a rain storm with no breaks. I was one hell of a ride and one I wouldn't want to experience again. Almost as bad as the bus ride to Aspen when a buddy of mine barf in the beer cart just before Vegas.

Sunday, February 11, 2007

 

Hang Gliding Adventures

Hang gliding could be one of the best sports around if it wasn't for all those damn rules and regulations. My instructors was a Maverick who choose to lived on the fringed of society. He has a college degree and was working a decent job once, but then decided that he didn't like the office and left a well paid career behind. He had a couple of nice plots of land that should be worth a pretty penny today. But to make ends meet, he used to chop firewood and rented out a decent house while he lived in a trailer out back. He didn't bother with health insurance. When his arm broke, he set it himself. When he had allergy attack, she stuck max up nose instead of taking medication. A minimalist a full decade before the fad caught on.

His first experience with hang gliding was from a friend who flew over him and called his name from the sky. He looked all around and couldn't see the guy until he looked up. He got hooked ever since. He used to train hawks or falcons. One of his birds would fly with him until it got kill by an eagle.

He didn't care too much for BS regulations, but he had enough common sense to keep us safe. He took me and a buddy to a couple of sites where we could fly high, before we were qualified to do so at the local sites. It's amazing how cold it gets at 10K' feet. My buddy quit after a little mishap and I soon followed. One problem with hang gliding is, some sites are so remote, it can take up to 2+ hours to get to a hospital. This was also in the day back when neither of us had a cell phone or GPS.

One of our best moments was the 2 of us driving up a 20 degree dirt road that's usually reserved for 4 wheel drives at slow speeds. He had an old Chevy Citation. He floor that baby at the bottom and bounced up the hill like a monster truck in a car crushing contest. It overheated at the top but the car ride was infinitely wilder than the flight down.

My scariest moment was a short flight when I got tangled in my harness. I couldn't zip up and the landing site was 5 miles away. I dragged too much and I was just staring at the tree line for 10 minutes. I eventually found a small patch of open space just beyond a line of tress I cleared by no more than 20'. The patch was small and it had a large row of bushes in the middle. After clearing the 100' tress, I pulled in for as much speed as possible cause I knew there's going to be a nice wind shadow waiting for me. As I'm cruising near the ground at 25-30 mph with zero head wind, I had to pop up over the bushes in the middle of the patch. That almost stall me, but I pull in and just managed enough speed to go another 10', pop out my one untangled leg, flared and landed perfectly on that one leg. I generally like to flare and run a bit instead of stopping on a dime. It's less elegant, but I think you're less likely to get pushed around by gust in a winding landing zone.

Once, I was down in the LZ watching a guy name Steve come down. He was just starting out and I was down there with his wife, who was holding their baby. Steve really love to fly and his wife was the most understanding woman I know. Not only did she just gave birth, but they live in an apartment, and Steve's hang gliding sits on their living room floor. At close to 20', I imagine it's quite intrusive. On this particular flight, Steve was on a hill side 300' above the LZ. He ran down the hill side and got air born quickly. But suddenly, he banked right and disappeared behind the hill side. She was a paled lady, but never as pale as she was at the one moment in time. All that I could think to say was, "I'm sure Steve's all right." And he was, but we didn't find out for the 10 longest minutes of her life.

I discovered quickly that I get air sickness. I tired it all kinds of remedies: ginger pills, pressure points, dry patch behind the ear, and oval medication, but nothing seem to help. My eventual solution was to bring my camel pack. That way, I can drink some water after I throw up, which is almost always 15 minutes into a bumpy flight, and after which, I feel completely fine.

I still got my CG2000 harness, a DOT motocross helmet, and maybe my friend's altimeter. The CG2000 was a kick ass harness with a single strap connected to the glider, unlike most harness with a web like connection that makes one look like a marionette. I still kept little wheels on the base tube. That helps to save a down tube on a bad landing despite making one look amateurish. I'll see if I can set it up in the garage and spin the kids around.

 

Roadster Update

My wife decide on the Titanium color Lotus Elise. We plan to check out the local dealer soon, but she doesn't drive stick yet. She's going to hire someone to teach her, and she won't even entertain the idea or me or a family member teaching her. That's a wise decision. (Update: she decided she really wanted an automatic after all so the Lotus was dropped from the list.)

I'll going to get a Miata soon so she can practice on it. There's a wide selection under 7K. I'll also check out a local used lot call Wheel and Deal. Tomorrow, I'll call some lady who was suppose to call me today. My car is going to the shop, so I won't be able to stop by Wheel and Deal until it's fixed. Hopefully in a day or two max.

If I can get a car this week, I may be able to register for an autocross this weekend up in the city. It's about 50 miles from here. I'll go check it out regardless with 2 other guys.

It seems the Spec racing is out due to time constraints. But that's still a goal.

My wife originally had some reservations about me racing cars, but I suggested that maybe I should start hang gliding again. For some reason, she likes that even less.

Thursday, February 08, 2007

 

Roadsters

My youngest daughter started daycare this week, so the wife can finally get out. Step one is getting a new car. It's unfortunately I sold off the convertible when we got the minivan. Here's the list of roadsters we've considered

1. Viper - This is her dream car, but it's too expensive for us right now. The older one are in our price range, but she doesn't want something that's 8+ years old.

2. Z4 - Strong contender, but still a bit pricey. The loaded models are $45K to $50K out the door.

3. Miata - My wife thinks it looks lame.

4. Audi TT - She really like it for a while, but doesn't like the look anymore. I think it looks like a VW Bug with a lower roof.

5. S2000 - No automatic option

6. Z350 - A guy car

7. Lotus Elise - My son's favorite in our price range, but it's not a convertible and it's a guy car. I'll go test drive this with my son.

8. Boxster - No one liked it. (Update: We changed our minds and got this car. The look started to grow on us, especially after looking at the real thing a few times.)

9. Eclipse - My wife thinks her '97 was the best model ever

10. Solstice - Looks great, but got poor reviews. We'll go look at the newer ones with the 260hp.

11. SKY - I hate it when someone captializes every letter in a word. My wife doesn't think it looks as nice as the Solstice, but it's got better reviews.

12. MINI - She thinks it's gay, if one can imagine a car with sexual orientation.


I'm considering getting a car, but I'll have to see how much is left over after the wife gets hers. Regardless, I'll be getting a used car:
1. Miata - For autocross and Miata Spec racing. Spec is ~$12K for car only or ~$5K for donor

2. Neon - For autocross and Neon Spec racing. I prefer the Miata.

3. '63 to '67 Vette - That's until I research these and found out how much they cost.

4. Pre '63 Vette - Same as the above, but I already knew it's out of my price range before I started looking.

5. Early 80s RX7 - These were great for Spec racing. Spec racer with extras is ~$4K w/ trailer

6. '93+ RX 7 - Biggest bang for the buck, especially if some kid's already put a bunch of mods on it.

7. Evo - Great cars, but I'm cheap so I figure the '93 RX 7 will provide a similar ride for less $. I'll keep an eye on these in the used market in the coming years. Plus it's all wheel drive and I believe there's a rally club a couple of hours north of here. An old Audi or Subaru may be more cost effective here.

8. Cataham like kit cars - If I ever get the time to DIY or find a good deal from a professional build, I would love to get one of these. It's not much safer than a motorcycle, but damn fun to drive. A Super 7 is preferred.

9. Alfa Remeo - I love that the stick is on the dash, but I heard the reliability is pretty bad. The replacement parts are harder to find and more expensive.

Thursday, February 01, 2007

 

Fairness is for Wusses

You got to queue some tasks, so you put it in a FIFO or multiple FIFOs and RR them right? If the system is blogged down, then everyone still gets there fair share of the resources and get blogged down evenly.

Think about that for a second. Say you got sever whose clients all start to run some heavy processing application at the same time. You let them all run, and everyone will complain that it's too slow and the system is unusable. No one is happy in this scenario.

What would happen if you used an unfair system like a stack for the task queue? The last people to start the application gets all the CPU cycles and their applications run fine. The first people to start the application times out and have to try back later. Some people are happy in this scenario. The worst case wait period, in theory, is just as bad as the worst case wait period in the FIFO scenario, but the user experience on average is much better.

 

Why C++ won't compile my C code or verse versa

This is a running list of stuff that I'll continue to update.

Why C code doesn't compile in C++?
1. Incrementing an enum is not allow in C++.



Why C++ code that uses only C syntax won't compile in C?
1. C doesn't allow the same const variable to be declared in multiple files unless it's static.

 

NAT is not a Firewall

My experience is quite dated here.

A NAT is a very basic firewall. You can specify which ports are open and where to route that traffic. When a machine access the Internet through a NAT, it's more protected than a machine that is not. It's one a few ports that are open and not every port.

To be consider a firewall however, you'll need to pass some security audits. You basic NAT will not pass this test. A NAT doesn't need to track the TCP state for open sessions. A NAT doesn't check if a new session for an application is coming from the correct source. A NAT doesn't check for DOS attacks or a security scans. A NAT box does not consider security very much.

Basically, a NAT is a firewall that's not secure enough to be call a firewall except by the most evil of marketer. Back in the late 1990s, some companies did market NAT as a firewall. Make sure your firewall is from a know security vendor(such as Cisco or Checkpoint) or has a ICSA or other recognized 3rd party certification. Best to google them to see what people say.

 

Prefetching Data & Hardware Registers

Some older processors may not support prefetch.

Try the gcc __builtin_prefetch__ function first.

When that doesn't work, you need to write inline assembly. See my MIPS assembly post for a prefetch code for a MIPs processor.

Always instrument you code first to see where there are high cache misses. Once you identify which the offending data structures, see if it's possible to reduce the size. Some times, people write overly large structures thinking that they're trading size for performance. This is especially true for hash tables.

If you've done all higher level optimization first and it's still not fast enough, then it may be time to prefetch. Remember that prefetch does take cycles and system resource. If the code accesses a piece of data 1000 times and miss the cache once, it's probably not worth prefetching. You can tell if prefetching is worth while by carefully instructing the code first.


It's also possible to prefetch a hardware register, but it's a PITA and I've never found the trade-offs worth while for a production level code.

1. Reserved a GPR(general purpose register) to store the prefetch value
GCC has a compiler option xxx which allows you to do this.
You don't want to take away this register from everyone so I suggest you separate the code that's going to reserver this register into it's own file to only that file or directory reserves this register.
Make this register a non-clobber register if you intend to make subroutine calls between the time you prefetch until you use the prefetched value.

2. Write inline assembly to load from the hardware register to this GPR.
The CPU won't block waiting for this transfer to finish. However, the CPU will block if anyone attempts another operation using this GPR.
3. Write inline assembly to load from this GPR to whatever variable you want to use.
If the load operation is not finished, then the CPU will block, but you've still saved some valuable cycles.

Obviously, the hardware register that was prefetched is out of date by the time you use it.

 

Rings and the Power of 2

Create ring buffers whose size is a power of 2 to improve performance. This allows you to index with an bit_or operation instead of a mod or condition check for boundary.

Examples of write routine for a ring buffer.

#define RING_SIZE (10)
int ring_idx = 0;
int ring_buf[RING_SIZE];

int ring_write(int val)
{
ring_buf[ring_idx++] = val;
if (ring_idx == RING_SIZE);
ring_idx = 0;
}

or

int ring_write(int val)
{
ring_buf[(ring_idx++) % RING_SIZE] = val;
}

Example with a ring size that's a power of 2:
(This code is not tested, but I've tested similar code. So the concept works, but there may be a bug.)

#define RING_POW 5
#define RING_SIZE (1 << RING_POW)
#define RING_MASK(RING_SIZE - 1)

int ring_idx = 0;
int ring_buf[RING_SIZE];

int ring_write(int val)
{
ring_buf[(ring_idx++) | RING_MASK] = val;
}

The assumption here is that a bitwise-or operation is much cheaper than a condition branch or a mod operation. That's true on all processors I've worked on. Maybe some DSP or math coprocessors are able to perform really quick mod operations.

 

Beware of objdump and inline assembly

In the inline assemby, you can change the cpu mode with a directive such as .set mips4. Unfortunately, the objdump doesn't know this directive since it only looks at the object file. Sometimes it'll incorrectly decode a machine code.

I ran into this problem with the prefetch code. The assembly instruction pref was decoded to lw??. You have to provide a cpu mode options to objdump similar to how to specify the cpu mode to the compiler.


This page is powered by Blogger. Isn't yours?