{"id":12573,"date":"2011-08-09T04:20:33","date_gmt":"2011-08-09T09:20:33","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=12573"},"modified":"2011-08-09T11:09:26","modified_gmt":"2011-08-09T16:09:26","slug":"john-carmack-2011-keynote-annotatedpart-2-of-3","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=12573","title":{"rendered":"John Carmack 2011 Keynote Annotated:<br\/>Part 2 of 3"},"content":{"rendered":"<p>Here is part 2 of my commentary of John Carmack&#8217;s Quakecon 2011 keynote. As before, the entire presentation is first, followed by my comments, with links to timestamps.<\/p>\n<p><table class='nomargin' cellspacing='0' width='100%' cellpadding='0' align='center' border='0'><tr><td><iframe loading=\"lazy\" width=\"1024\" height=\"576\" src=\"https:\/\/www.youtube.com\/embed\/4zgYG-_ha28\" frameborder=\"0\" allowfullscreen class=\"embed\"><\/iframe><br\/><small><a href='http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28'>Link (YouTube)<\/a><\/small><\/td><\/tr><\/table><\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=20m10s\">20:10<\/a><\/h3>\n<p>Carmack talks about the PS3 and the way its memory space  is divided up. This has always been a hot-button topic when I&#8217;ve tackled it, but it&#8217;s been a few years since we had that conversation.  Perhaps heads have cooled and we can try again&#8230;<\/p>\n<p><!--more-->This is a big part of why I was so frustrated with the PS3 hardware after release.  Sony said things about how fast their processors were and about how much memory the thing had, and all of that was technically true while being irritatingly beside the point from an engineering standpoint.  There&#8217;s a lot of memory there, but it&#8217;s Balkanized into these chunks with fixed uses. There are a lot of processors, but they all have fixed uses as well. So you end up with situations like this one, where the PS3 actually has less useful memory than the Xbox 360.<\/p>\n<p>Sony got away with this because the explanation for why their machine wasn&#8217;t better was highly technical.  <a href=\"http:\/\/www.1up.com\/news\/gabe-newell-ps3-total-disaster\">Gabe Newell famously criticized the machine<\/a>.  Sony fans, most of whom are not programmers, couldn&#8217;t really understand the inherent problems in developing for highly unorthodox hardware, and wrote him off as a PS3 hater. I got the same treatment when I <a href=\"http:\/\/www.escapistmagazine.com\/articles\/view\/comics\/stolen-pixels\/5838-Stolen-Pixels-71-PS3-Exclusive-Interview\">made fun of the thing<\/a>.  (Only <a href=\"http:\/\/www.escapistmagazine.com\/articles\/view\/comics\/stolen-pixels\/6629-Stolen-Pixels-132-Special-Guest-Master-Chief\">making fun of Halo caused<\/a> more fury and personal attacks.) <\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/quakecon4.jpg' class='insetimage'   alt='quakecon4.jpg' title='quakecon4.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>Imagine you&#8217;re running a warehouse filled with consumer goods, and it&#8217;s your job to move stuff around. Let&#8217;s say it&#8217;s the storage area for a big-box store. You need to receive new goods from the loading area, store it on shelves, and move the goods out to the other side when they&#8217;re ready to be put out for sale. In the Xbox warehouse, you have just one forklift, which can handle 2,000 lbs. In the PS3 warehouse, you have a forklift for moving consumer electronics, another forklift for moving kitchen appliances, another for furniture, another for clothing, another for toys, and another for &#8220;everything else&#8221;.  All of these can handle 1,000 lbs.  The people who designed the PS3 warehouse will tell you that you have six fork trucks that can move 1,000 lbs., which means you can move stuff <em>three times as fast<\/em> as those losers in the Xbox warehouse.  <\/p>\n<p>But the truth is that it&#8217;s really hard to keep all of those trucks moving without them getting in each other&#8217;s way. You only need to move toys once a week and furniture every other day, so those fork trucks are rarely used. The restrictions on what each truck can carry imposes restrictions on how you can lay out your goods.  For example, popular things like consumer electronics and kitchen appliances can&#8217;t be stored on the same aisle or the trucks would block each other, so one of them has to be moved to a less-optimal location.  And finally, the trucks themselves take up a lot of floor space, leaving less room for moving around and storing goods.  <\/p>\n<p>In the end, the speed gains from having six forklifts is nearly negated by the various limitations. Worse yet, the extra expense is incredible, the job is a lot more complicated, and there are some things you simply can&#8217;t move because they&#8217;re too heavy for your trucks.  The worst part is, everyone keeps telling you that you should be moving things three times as fast.  When you try to explain that it&#8217;s not that simple, they tell you you suck. &#8220;Do you know how expensive this hardware is?  If you can&#8217;t make it go faster then <em>you&#8217;re<\/em> the one with the problem.&#8221;  <\/p>\n<p>From a software engineering standpoint, it&#8217;s going to take a lot of work to put any of that extra PS3 power to use.  That extra work will only benefit your PS3 version, and does nothing for the PC and Xbox 360 versions. If you don&#8217;t do that extra work, your game won&#8217;t be using the machine to its fullest and all that expensive processing power the user bought will be going to waste.<\/p>\n<p>I still believe, as <a href=\"http:\/\/www.escapistmagazine.com\/articles\/view\/columns\/experienced-points\/6280-Activision-vs-Sony\">I asserted a couple of years ago<\/a>, that the PS3 was engineered in such a way as to choke off the competing platforms by building a developmental wall around Sony to make porting difficult.  This would have increased the number of de facto exclusives.  However, with them trailing in market share, the wall is working the other way and keeping developers from bothering to port to this quirky, unconventional beast. Ironic justice, I suppose. (Assuming I&#8217;m right. Note that this is all conjecture on my part.  I think it explains Sony&#8217;s behavior better than, &#8220;they were just dumb&#8221;, but we&#8217;ll never know what <em>really<\/em> happened inside the company unless someone writes a tell-all book.)<\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=20m55s\">20:55<\/a><\/h3>\n<p>Blu-ray drives are slower (latency) than DVD&#8217;s? I did not know this.  That makes the earlier problems even more pronounced. If you decided to alleviate the congestion problems in the PS3 warehouse by keeping less goods on hand and simply ordering smaller batches of goods more often, now the ordering system is set up so that there&#8217;s a longer wait between the time you order more televisions and the point where they show up in receiving. And now I&#8217;ve probably stretched this warehouse metaphor too far.<\/p>\n<p>To be fair, I don&#8217;t know how big the delta is between DVD and BR read speeds.  Note that this is about latency, not throughput.  BR can probably deliver more total data a second, but it takes longer between the time you request a block of data and the time when data actually arrives in memory. It&#8217;s another case of the PS3 hardware limitations exacerbating each other.<\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=21m55s\">21:55<\/a><\/h3>\n<p>&#8220;Four levels of locality&#8221; &#8211; this is indeed a complicated system.  At first the data is sitting on your optical media. (DVD or BR) Then it gets pulled in, which takes a long time as computers reckon things.  To spare you that wait the next time the data is needed, this data is saved in a temporary file on the hard drive. (I can&#8217;t believe this game will actually run on an Xbox with no hard drive. Amazing.) The data is also held in general memory.  And finally, the data is put into graphics memory, where the texture is available for rendering. <\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=26m25s\">26:25<\/a><\/h3>\n<p>When he says &#8220;Tex sub image two dee&#8221;, he&#8217;s talking about <a href=\"http:\/\/www.cs.sfu.ca\/~haoz\/teaching\/htmlman\/texsubimage2d.html\">glTexSubImage2D ()<\/a>, which is an OpenGL function. This function takes a block of memory and places it into a texture in memory, or a portion of a texture.  Going back to my example image:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/quakecon2.jpg' class='insetimage'   alt='quakecon2.jpg' title='quakecon2.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>You&#8217;d use this to replace the contents of one of those little squares. I use this heavily in <a href=\"?p=12123\">Project Frontier<\/a>, when generating the terrain textures. I&#8217;m sort of terrified to think about what might be going on under the hood in my program.  Some of my textures are as large as 2048&#215;2048, and if glTexSubImage2D () copies the entire thing in memory when I update a little 128&#215;128 patch of it, then that&#8217;s a really painful performance hit. Best of all, it sounds like it only happens on some systems, or with some drivers. Wonderful. <\/p>\n<p>It says a lot that even after these years of working with DirectX, Carmack still speaks (and perhaps thinks) in terms of OpenGL.  <\/p>\n<p>He&#8217;s explaining that glTexSubImage2D () has a <em>lot<\/em> of stuff happening in the background that can make it painfully inefficient in some circumstances. He&#8217;s explaining this to illustrate how PC can still struggle, even though it&#8217;s ten times as powerful as a console.  On the console side, the program has direct access to video memory.  On the PC side, you have to navigate everything through the ever-changing landscape of graphics drivers, which might be doing all kinds of extra processing that you don&#8217;t need. It relates to the <a href=\"?p=11318\">dirt road problem<\/a> I discussed before.<\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=27m15s\">27:15<\/a><\/h3>\n<p>&#8220;Intel&#8217;s current graphics hardware is getting decent&#8221;.  I didn&#8217;t know this, and it&#8217;s an interesting twist.  Basically, those crappy, built-in graphics cards on cheap PC&#8217;s and laptops are approaching the power and functionality needed to run games properly.  The problem has been that there was never much of an incentive for Intel (or other manufacturers) to make their built-in graphics hardware better. Why spend money on it?  Most people won&#8217;t care, and the ones that do care are the ones who will probably buy a $200 graphics card anyway.  So Intel just puts the cheapest hardware it can in there. <\/p>\n<p>I&#8217;m sure they&#8217;re still putting the cheapest stuff in, but things have advanced so far that even the cheapest graphics hardware is good enough to nearly keep up with the current-gen consoles. If this trend continues and we don&#8217;t suddenly get another console generation, then we&#8217;ll see an increase in the number of PC&#8217;s that can run games without needing to buy a graphics card.  I doubt it will ever be enough to make the PC a true market rival to the consoles, but in the long run we might get a few more ports, and PC ports might be less horrible. In an ideal world, graphics cards will be for people who want to run the game at max settings on a ginormous monitor, and people content with medium settings won&#8217;t need one.<\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=30m20s\">30:20<\/a><\/h3>\n<p>&#8220;A thousand characters should be enough&#8221;.  Sigh.  C++ takes a lot of flak for this, because this is a really common problem in the language.  A programmer needs to reserve some memory to hold something.  A person&#8217;s name, a directory name, a list of available fonts, or whatever. You have no idea how big this data will be.  The sloppy solution is to just imagine what you think will be the biggest number you&#8217;ll need, multiply by two, and use that. If I need to store the name of a place, I might think 40 characters is enough, so I&#8217;ll reserve 80 bytes &#8220;just in case&#8221;.  Then someone from <a href=\"http:\/\/en.wikipedia.org\/wiki\/Taumatawhakatangihangakoauauotamateapokaiwhenuakitanatahu\">Taumata\u00c2\u00adwhakatangihanga\u00c2\u00adkoauau\u00c2\u00ado\u00c2\u00adtamatea\u00c2\u00adturi\u00c2\u00adpukakapiki\u00c2\u00admaunga\u00c2\u00adhoro\u00c2\u00adnuku\u00c2\u00adpokai\u00c2\u00adwhenua\u00c2\u00adkitanatahu<\/a> shows up, the program tries to store the 97-character name in the 80-character slot, and Things Go Wrong.  (If you&#8217;re lucky, you just crash.)  <\/p>\n<p>The forward-thinking (but still lazy) programmer might avert this by reserving TEN times the space he thinks will be needed, but that will eventually lead to a lot of wasted memory, and won&#8217;t <em>really<\/em> solve the problem in a guaranteed-safe way. <\/p>\n<p>As Carmack warned elsewhere in his talk, this is the stuff of holy wars. <\/p>\n<p>&#8220;This language is flawed because you can shoot yourself in the foot.&#8221;<\/p>\n<p>&#8220;ANY good tool can be used wrong.  It&#8217;s only a problem if you&#8217;re a bad programmer.&#8221;<\/p>\n<p>Programming languages all have trade-offs.  Readability. Learning curve. Performance. Portability. Consistency. Availability and usefulness of third-party libraries. The cost of maintaining code. Breadth of built-in tools. Flexibility. When people argue about which language is best, they&#8217;re usually gathered around the fault lines formed by these various trade-offs.  <\/p>\n<h3><a href=\"http:\/\/www.youtube.com\/watch?v=4zgYG-_ha28#t=33m00s\">33:00<\/a><\/h3>\n<p>The tear-line problem:<\/p>\n<p>Your monitor updates at a fixed interval.  Your videogame does not.  If the game isn&#8217;t done drawing the next frame of the game, the monitor can simply repeat the last image you were shown, and you&#8217;ll have to wait for the next monitor refresh to see the new image. The upshot is that if the game dips below 60fps, you&#8217;re effectively going to be seeing 30fps.  If the game misses 30fps, it dips to 15fps.  If the game is running at (say) 20fps, then some frames take twice as long as others to appear, and the game will shift between 15 and 30 fps.  I can feel and see this when it happens, and it&#8217;s annoying.  (The same effect of bouncing between 30 and 60fps is much harder for me to detect. It&#8217;s one of those things that some people can&#8217;t notice, but which drives other people crazy.)<\/p>\n<p>The other solution is for the game to show the new frame as soon as it&#8217;s done, even if it&#8217;s not time for a new frame.  You might have noticed this option in games, usually labeled as &#8220;disable vertical sync&#8221;.  It will just slap the new image into place, ready-or-not.  This leads to situations where the part of the screen is the new frame and part of the screen is the old one, like so:<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/quakecon3.jpg' class='insetimage'   alt='Vertical tearing.  (Simulated.)' title='Vertical tearing.  (Simulated.)'\/><\/td><\/tr><tr><td class='insetcaption'>Vertical tearing.  (Simulated.)<\/td><\/tr><\/table><\/p>\n<p>I&#8217;ll add that 60fps is really, really hard to maintain in a complex game with lots of things going on.  You need to have your threads and your scheduling working just perfectly. 30fps is many, many times easier to pull off.  I&#8217;m anxious to play Rage, just to see how much I can feel the difference. It&#8217;s been <em>years<\/em> since I played a new game that ran at that speed.<\/p>\n<h3><\/h3>\n<p>We&#8217;ll wrap up this series tomorrow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is part 2 of my commentary of John Carmack&#8217;s Quakecon 2011 keynote. As before, the entire presentation is first, followed by my comments, with links to timestamps. Link (YouTube) 20:10 Carmack talks about the PS3 and the way its memory space is divided up. This has always been a hot-button topic when I&#8217;ve tackled [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-12573","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/12573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12573"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/12573\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}