Ian Wienand: An open letter to the bald-headed salesman in Harvey Norman, Norwest, Castle Hill
I usally find blog rants useless, but sometimes something is just
so annoying one is sufficiently inspired. Today I went with my
parents to buy them a Tivo at Harvey Norman, Norwest, Castle Hill,
NSW, Australia. I am a big Tivo fan; the interface is good and it
"just works". I don't mind paying for (or in this recommending paying
for) good products.
After selecting the Tivo model, I asked for a HDMI cable. The
salesman made a series of questions about what sort of HD TV it was
being plugged into; I quickly sensed this as a probe to see what sort
of suckers we were, and requested just a "normal" cable.
At this point, he insisted on a $130 (you guessed it)
Monster cable, and had the audacity to say that we didn't need one of
the really expensive cables because our TV wasn't good enough!
I openly expressed my concern, but the annoying high-pressure sales
pitch had just begun. The amount of, frankly, crap that he spewed
about 4-bit this, 10-bit that, legislating of labels, DA signal
levels, mythical customers who regretted buying the cheap cables and
who knows what else was to the point of being comical if it weren't so
insistent and said with such seeming authority.
There is only one thing that matters - if the cable has passed the
functional requirements for being certified to have the distinctive
HDMI logo plastered on it. From the HDMI FAQ:
Q. What testing is required? Prior to mass producing or distributing any Licensed Product or component that claims compliance with the HDMI Specification (or allowing someone else to do such activities), each Adopter must test a representative sample for HDMI compliance. First, the Adopter must self test as specified in the then-current HDMI Compliance Test Specification. The HDMI Compliance Test Specification provides a suite of testing procedures, and establishes certain minimum requirements specifying how each HDMI Adopter should test Licensed Products for conformance to the HDMI Specification.Now, I can understand that if you buy any old HDMI cable off Ebay for $1, it may be a knock-off that uses the HDMI logo illegally. But there is no way that the certified $50 Philips cable (still very over-priced, but at least not insane, and discounted to $35) performs any differently to some overpriced Monster model certified to exactly the same standard. The thing that annoyed me most was his analogy to buying a tyre. He stated that "if you walked up to a tyre salesman and I said don't want the Pirelli's, just put the cheap-o tires on my Ferrari" I'd be insane, and thus by extension of that logic I was insane for not buying a Monster cable for my great new Tivo. This analogy is completely flawed and really just dishonest. A Ferrari is much more powerful and goes much faster than a standard car. It is plausible it needs a better engineered tyre to perform adequately given the additional stresses it undergoes. A Tivo doesn't put out any more or any less bits than any other HDMI certified equipment, no matter what you do. If the cable is certified as getting all the bits to the other end under whatever environmental conditions specified by the HDMI people, then it's going to work for the 99% of people with normal requirements. Nobody wants to make a significant investment in a piece of audio-visual equipment and feel they are getting something that isn't optimal. Harvey Norman's use of this understandable consumer sentiment to sell ridiculously over-priced cables that do nothing is extremely disappointing. I'm sure the commissions on these things encourage this behaviour, so it is useless expecting the retailer or individual sales assistant to change their policy to reccommend reasonably priced cables. However, it is really Tivo and other manufactuers who get the raw end of this deal; a $130 cable is over 20% of the price the actual Tivo! That is surely affecting people's purchasing decisions. If Tivo and others included a certified HDMI cable with their device, as they do with component cables, and had "Certified HDMI 1.3 cable included" plastered on the box, it would be a harder sell to explain why the manufactuer would bother shipping a certified cable that is supposedly insufficient, and consumers would hopefully avoid the very distasteful high-pressure theatrics I was subjected to today.
From this, I can see that Bandon, about a third of the way up the
Oregon coast, is a pretty good candidate. However, probably not the
best; I get the feeling the real point that is the furthest from any
city of 1 million people is actually somewhere in the central-middle
of Montana.
However, we can also fiddle the program slightly to disprove the
point about Bandon. The numbers show the closest large city to Bandon
is LA, at ~1141km. Taking another point we suspect to be more remote;
the closest large city to Portland (where we met the doorman) is also
LA at ~1329km. So to reach the closest large city you have to travel
further from Portland than Bandon, so Bandon is not the
furthest place in the USA from a city of one million people. Myth
busted!
Serve creates goroutines via the go
keyword; each of which tries to get a slot in the channel. In the
example there are only 3 slots, so it acts like a semaphore of count
3. When done, each thread returns its slot to the channel, which
allows anyone blocked to be woken and continued.
This instantly reminded me of the very first thing you need to do
if you ever want to pass
Look familiar? Instead of a blocking push of a number into a slot
into a channel, you make a blocking IPC call to a remote server.
My point here is that both take the approach of sharing memory via
communication. When using IPC, you bundle up all your information
into the available slots in the IPC message and send it. When using a
channel, you bundle your information into an entry in the channel and
call your goroutine. Receiving the IPC is the same as draining a
channel - both result in you getting the information that was bundled
into it by the caller.
This seems to give quite useful results with a bare minimum of
effort, and most importantly no tricky floating point math. For
example, on the standard Unix words with a 2048 entry
hash-table, the standard DJB hash came out very well (as expected)
The image above gives some idea of how it works. We can examine
relocations with the readelf tool.
As shown above, the GOT ensures the abstraction required so symbols
can be diverted as expected. Each entry is essentially a pointer to
the real data (hence the extra dereference in the code above). Since
the GOT is at a fixed offset from the program code, it can use an IP
relative address to gain access to the table entries.
This extra reference is obviously slower; however for the most part
I imagine the overhead would be essentially immeasurable and is
required for "generic" operation. If you have figured the cost of
indirection through the GOT is the major bottleneck of your program, I
imagine you wouldn't be reading this and would already be considering
strategies to remove it!
The next question is why this works on plain old x86-32.
Inspecting the code reveals why:
In the first example, there was not enough information to tell if
the function would ever be able to be overridden, hence a PLT entry
had to be created and the function called through it (disassemble it
to see the details!). With correct symbol visibility attributes,
there is enough information to know that
common_but_not_part_of_api is never to be overridden, hence
the PLT (and the associated costs of trampolining) can be avoided.
The internal attribute is even stricter; it says that this
function will never be called from outside this module (for
example, we might pass the address of
common_but_not_part_of_api to anyone). This can lead to even
better code, because on many architectures transitioning to another
module might involve flipping global pointer registers or other
similarly expensive operations.
So that's how symbol binding and visibility attributes can work
together to get you the best performance possible from your
program!