New computer

October 24th, 2008

I was shopping for a new computer at Alienware this morning. Some of their upgrade prices, especially for RAM, looked fishy. You can get what appears to be the same items from Newegg for less than what Alienware charges as the upgrade price. The upgrade price means additional cost to what you are already paying for the base component. This seemed especially true for the 2 GB low latency patriot memory upgrade. Alienware wanted an additional $600 but I can apparently buy this from NewEgg for $240.
The memory from NewEgg

If the items are not equivalent I’ll correct this but they definitely need to work on justifying why I should pay $600 for 2 GB of memory.

I found Cyberpowerpc.com which gives you a great deal of freedom in what parts to pick. I built a computer that would cost about twice as much from Alienware. The only problem is that it’s very hard to know what parts to pick given the wide range of options, some of which are incompatible. The website form isn’t that good either, often resetting your choices if you go back and forth between pages.

I basically ordered the top of the line AMD, with dual top of the line video cards.

Code: ULTRASLIQUADZ $2,627.00 x 1 $2,627.00
Gamer Ultra SLI Quad (NO MONITOR)
www.cyberpowerpc.com/system/Gamer_Ultra_SLI_Quad/

*BASE_PRICE: [+2259]
CAS: NEW!!! CoolerMaster Cosmos Silent Gaming Tower Case w/ 420 Watts Power Supply (Original Color)
CASUPGRADE: NONE
CS_FAN: Default case fans
CPU: AMD Phenom(TM) X4 9950 Black Edition Quad-Core CPU w/ HyperTransport Technology [+16]
CD: (Special Price) LG 20X DVD+/-R/+/-RW + CD-R/RW DRIVE DUAL LAYER (BLACK COLOR)
CD2: NONE [-18]
CABLE: None
FLASHMEDIA: INTERNAL 12in1 Flash Media Reader/Writer (BLACK COLOR)
FA_HDD: None
FAN: Asetek Liquid CPU Cooling System (Extreme Cooling Performance + Extreme Silent at 20dBA)
FLOPPY: NONE
FREEBIE_OS: None
HDD: Single Hard Drive [-327] (300GB Gaming Western Digital Raptor 10,000RPM SATA-II 3.0Gb/s 16MB Cache WD3000GLFS [+244])
HDD2: NONE [-54]
IEEE_CARD: NONE
KEYBOARD: PS2 MULTIMEDIA INTERNET CONTROL KEYBOARD (BLACK COLOR)
MOUSE: Logitech Optical Wheel Mouse (BLACK COLOR)
MODEM: NONE
MONITOR: NONE
MONITOR2: NONE
MOTHERBOARD: (3-Way SLI Support) Asus Crosshair II Formular 780A SLI Chipset DDR2/1066 SATA RAID PCI-E MBoard w/GbLAN,USB2.0,IEEE1394,&7.1Audio [+155]
MEMORY: (Req.DDR2 MainBoard) 2GB (2×1GB) PC8500 DDR2/1066 Dual Channel Memory [+150] (Corsair Dominator)
NETWORK: ONBOARD 10/1000 NETWORK CARD
OS: Microsoft(R) Windows(R) XP Professional w/ Service Pack 3 [+61]
PRINTER: None
PRINTER_CABLE: None
PRO_WIRING: Professional Wiring for All WIRINGs Inside The System Chasis with High Performance Thermal Compound on CPU [+19]
POWERSUPPLY: 900 Watts Power Supplies [+38] (Apevia Warlock Series)
RUSH: RUSH!!! READY TO SHIP IN 5 BUSINESS DAYS [+49]
SERVICE: STANDARD WARRANTY: 3-YEAR LIMITED WARRANTY PLUS 24/7 LIFE-TIME TECHNICAL SUPPORT
SOUND: HIGH DEFINITION ON-BOARD 7.1 AUDIO
SPEAKERS: Logitech (BLACK) X-540 70Watts 5.1 Configuration Speaker System
TEMP: NONE (AS SHOWN)
TVRC: None
USBHD: NONE
USB: Built-in USB 2.0 Ports
VIDEOCAMERA: NONE
VIDEO: NVIDIA GeForce GTX280 1GB 16X PCI Express (EVGA Powered by NVIDIA [+5])
VIDEO2: NVIDIA GeForce GTX280 1GB 16X PCI Express (EVGA Powered by NVIDIA [+5])
VIDEO3: NONE
WNC: PCI Wireless 802.11g 54Mbps Network Interface Card + GigaByte GN-AT2050D 2.4GHz Indoor Omni-Directional Dipole Antenna [+25]
_PRICE: (+2627)

Memory heap allocator faster than new/delete

October 19th, 2008

Here’s a class that given a predefined area of memory, allows you to allocate and deallocate areas of that memory. In other words, a custom memory manager.

Only partially done yet, but it’s already 25% or so faster than malloc and free
Header
CPP

Full alloc, then dealloc
Heap = 1304 us
malloc = 878256 us

Fragmentation
Heap = 3525 us
malloc = 4462 us

Most of the speedup comes from linked lists of buckets. There are 7 buckets, from 32 bytes to 2048 bytes, incrementing in powers of two. 20% of the given memory is dedicated to buckets. If an allocation is requested and a bucket is available, the allocation goes to that bucket instead. Because buckets are contiguous and reserved, those allocations cannot cause fragmentation.

The alignment boundary is 32 bytes, so all allocations returned to the user are aligned, and the average memory wasted per allocation is 32 bytes, excluding buckets.

The speeds shown are with a critical section lock. This is not necessary, and for single threads it would be even faster.

Ron Paul on the bailout

October 14th, 2008

http://www.youtube.com/watch?v=TnWuUcL2otk

I’m moving my money out of US dollars. Foreign currency CDs are the best. Currently Canada has the most sound banking system, so is the least likely to suffer a depression when the dollar crashes.

By IQ scores, Palin is dumber than 85% of the population

October 10th, 2008

According to this site, McCain has a 15% chance of dying of old age while in office.
http://www.marshfieldnewsherald.com/apps/pbcs.dll/article?AID=/20081003/MNH06/810030395

The chance of Palin becoming president is higher than that, since you usually are unable to work for some time before dying.

So with that news, according to the public records on this site:
http://clapboard.org/temp/SarahPalinReport.pdf

Palin’s IQ is only 83, over one standard deviation, which means she’s dumber than roughly 85% of the population:
http://en.wikipedia.org/wiki/Standard_deviation

Most of my views lie with Republicans, but the last thing we need is another idiot in office. As much as I can’t stand socialism, I’m going to vote for Obama just so McCain doesn’t become president.

Representative votes for the bailout

October 6th, 2008

http://www.votesmart.org/issue_keyvote_member.php?cs_id=22467

Who is my representative?

California in particular.

Register to vote in California

The deadline to register is October 20, 2008.

  • CA 1 Rep. Michael Thompson Democratic Y
  • CA 2 Rep. Walter Herger Jr. Republican Y
  • CA 3 Rep. Daniel Lungren Republican Y
  • CA 4 Rep. John Doolittle Republican N
  • CA 5 Rep. Doris Matsui Democratic Y
  • CA 6 Rep. Lynn Woolsey Democratic Y
  • CA 7 Rep. George Miller Democratic Y
  • CA 8 Rep. Nancy Pelosi Democratic Y
  • CA 9 Rep. Barbara Lee Democratic Y
  • CA 10 Rep. Ellen Tauscher Democratic Y
  • CA 11 Rep. Gerald McNerney Democratic Y
  • CA 12 Rep. K. Speier Democratic Y
  • CA 13 Rep. Fortney Stark Democratic N
  • CA 14 Rep. Anna Eshoo Democratic Y
  • CA 15 Rep. Michael Honda Democratic Y
  • CA 16 Rep. Zoe Lofgren Democratic Y
  • CA 17 Rep. Sam Farr Democratic Y
  • CA 18 Rep. Dennis Cardoza Democratic Y
  • CA 19 Rep. George Radanovich Republican Y
  • CA 20 Rep. Jim Costa Democratic Y
  • CA 21 Rep. Devin Nunes Republican N
  • CA 22 Rep. Kevin McCarthy Republican N
  • CA 23 Rep. Lois Capps Democratic Y
  • CA 24 Rep. Elton Gallegly Republican N
  • CA 25 Rep. Howard McKeon Republican Y
  • CA 26 Rep. David Dreier Republican Y
  • CA 27 Rep. Brad Sherman Democratic N
  • CA 28 Rep. Howard Berman Democratic Y
  • CA 29 Rep. Adam Schiff Democratic Y
  • CA 30 Rep. Henry Waxman Democratic Y
  • CA 31 Rep. Xavier Becerra Democratic N
  • CA 32 Rep. Hilda Solis Democratic Y
  • CA 33 Rep. Diane Watson Democratic Y
  • CA 34 Rep. Lucille Roybal-Allard Democratic N
  • CA 35 Rep. Maxine Waters Democratic Y
  • CA 36 Rep. Jane Harman Democratic Y
  • CA 37 Rep. Laura Richardson Democratic Y
  • CA 38 Rep. Grace Napolitano Democratic N
  • CA 39 Rep. Linda Sánchez Democratic N
  • CA 40 Rep. Edward Royce Republican N
  • CA 41 Rep. Jerry Lewis Republican Y
  • CA 42 Rep. Gary Miller Republican Y
  • CA 43 Rep. Joe Baca Democratic Y
  • CA 44 Rep. Ken Calvert Republican Y
  • CA 45 Rep. Mary Bono Mack Republican Y
  • CA 46 Rep. Dana Rohrabacher Republican N
  • CA 47 Rep. Loretta Sanchez Democratic N
  • CA 48 Rep. John B.T. Campbell III Republican Y
  • CA 49 Rep. Darrell Issa Republican N
  • CA 50 Rep. Brian Bilbray Republican N
  • CA 51 Rep. Bob Filner Democratic N
  • CA 52 Rep. Duncan Hunter Republican N
  • CA 53 Rep. Susan Davis Democratic Y
  • For me, it’s John B.T. Campbell III. He voted yes, so I’m voting him out of office next month.

    Senators that voted for the mortgage bailout plan

    October 2nd, 2008

    Here’s the list of senators that voted for the amended version of H. R. 1424, the mortgage bailout plan

    1. Akaka (D-HI)
    2. Alexander (R-TN)
    3. Baucus (D-MT)
    4. Bayh (D-IN)
    5. Bennett (R-UT)
    6. Biden (D-DE)
    7. Bingaman (D-NM)
    8. Bond (R-MO)
    9. Boxer (D-CA)
    10. Brown (D-OH)
    11. Burr (R-NC)
    12. Byrd (D-WV)
    13. Cardin (D-MD)
    14. Carper (D-DE)
    15. Casey (D-PA)
    16. Chambliss (R-GA)
    17. Clinton (D-NY)
    18. Coburn (R-OK)
    19. Coleman (R-MN)
    20. Collins (R-ME)
    21. Conrad (D-ND)
    22. Corker (R-TN)
    23. Cornyn (R-TX)
    24. Craig (R-ID)
    25. Dodd (D-CT)
    26. Domenici (R-NM)
    27. Durbin (D-IL)
    28. Ensign (R-NV)
    29. Feinstein (D-CA)
    30. Graham (R-SC)
    31. Grassley (R-IA)
    32. Gregg (R-NH)
    33. Hagel (R-NE)
    34. Harkin (D-IA)
    35. Hatch (R-UT)
    36. Hutchison (R-TX)
    37. Inouye (D-HI)
    38. Isakson (R-GA)
    39. Kerry (D-MA)
    40. Klobuchar (D-MN)
    41. Kohl (D-WI)
    42. Kyl (R-AZ)
    43. Lautenberg (D-NJ)
    44. Leahy (D-VT)
    45. Levin (D-MI)
    46. Lieberman (ID-CT)
    47. Lincoln (D-AR)
    48. Lugar (R-IN)
    49. Martinez (R-FL)
    50. McCain (R-AZ)
    51. McCaskill (D-MO)
    52. McConnell (R-KY)
    53. Menendez (D-NJ)
    54. Mikulski (D-MD)
    55. Murkowski (R-AK)
    56. Murray (D-WA)
    57. Nelson (D-NE)
    58. Obama (D-IL)
    59. Pryor (D-AR)
    60. Reed (D-RI)
    61. Reid (D-NV)
    62. Rockefeller (D-WV)
    63. Salazar (D-CO)
    64. Schumer (D-NY)
    65. Smith (R-OR)
    66. Snowe (R-ME)
    67. Specter (R-PA)
    68. Stevens (R-AK)
    69. Sununu (R-NH)
    70. Thune (R-SD)
    71. Voinovich (R-OH)
    72. Warner (R-VA)
    73. Webb (D-VA)
    74. Whitehouse (D-RI)

    Morgage bailout in two paragraphs

    September 22nd, 2008

    2002:

    200 million a year banker: “Hey, lets give credit to anyone that wants to buy a house, regardless of income or credit. We can sell these loans as securities, and leverage it out 30 to 1.”
    Irresponsible buyer: “Wow, I can buy a mansion even though I work at 7-11″
    Average taxpayer: “These housing prices are insane. I’m going to keep renting.”

    2008:

    Irresponsible buyer: “Hey, my 200K house isn’t worth a million dollars now that nobody wants to pay for it. Cya.”
    200 million a year banker: “The economy is fucked unless the taxpayers pay for our bad loans.”
    George Bush: “Have a trillion dollars.”
    Average taxpayer: “WTF?”

    Contractor pay calculator

    September 12th, 2008

    It’s been coming up a lot lately on how much I should ask for to work as a contractor, given a certain pay value as an employee. Every time I do this in my head, an hour later I kick myself because I realize I asked for too little. So I wrote a calculator in Javascript that will do all the calculations for you.

    Contractor pay calculator

    I’ll leave it up to the reader to write the inverse operation :)

    Jeopardy done

    September 10th, 2008

    First major game to show the RakNet logo prominently. There’s another AAA game out there that uses RakNet but they don’t show the logo.
    http://www.us.playstation.com/PS3/Games/JEOPARDY

    Unfortunately, they edited the middleware splash screen out of the video on the site.

    The most difficult part of contracting on this project was working with 3rd party code. This is one of those cases where it would have been faster to write your own systems from scratch. In the end it did well though and the game is pretty much bug-free.

    Lobby 2 almost done

    September 1st, 2008

    I’m almost done writing the new lobby system (Lobby2) for RakNet. The original design had a huge list of functions in a single class such as:

    virtual void RegisterAccount(LobbyDBSpec::CreateUser_Data *input, SystemAddress lobbyServerAddr);
    virtual void UpdateAccount(LobbyDBSpec::UpdateUser_Data *input);
    virtual void ChangeHandle(const char *newHandle);

    You would get back a callback with a result code, such as

    virtual void RegisterAccount_Result(LobbyClientCBResult result){};
    virtual void UpdateAccount_Result(LobbyClientCBResult result){};
    virtual void ChangeHandle_Result(LobbyClientCBResult result){};

    The mistakes I made were:

    1. The database was designed to be more like a file system, storing the results of commands executed in C++, rather than processing the commands themselves. The problem was this was a huge amount of code. Sometimes it wasn’t really possible to synchronize the C++ and the database. Complex cases such as not allowing clan commands unless you were the clan leader were not handled well.
    2. Result codes were generic and reused between commands. The problem was that this was imprecise. Sometimes more than one result code could apply, and you were never really sure which result codes could be returned.
    3. You often didn’t have sufficient context about what the result is referring to. For example, if I got a change handle callback that failed because the name was already in use, what name had I been trying to change to?
    4. The only way to extend the system was to derive a new class, understand the flow of the whole system, and write a huge amount of code.

    On the positive side, having everything in one class did lead to good encapsulation and efficiency. All the systems could work together very smoothly with maximum performance efficiency.

    In my own defense, a certain platform I have been programming on makes mistakes 2 and 3 as well.

    Anyway, I’ve rewritten the system with those mistakes in mind.

    1. The database performs the actual functionality, with almost no operative code in C++. This is more scalable, easier to extend, and can handle cases of any complexity.
    2. Result codes are specific. There’s a small set of shared result codes, such as:

    L2RC_SUCCESS,
    L2RC_DATABASE_CONSTRAINT_FAILURE,
    L2RC_PROFANITY_FILTER_CHECK_FAILED,

    Besides that, the result codes directly apply to operations. So you know not only what codes you will get, but what codes you won’t get.

    {REC_ENTER_ROOM_UNKNOWN_TITLE, “Failed to enter a room. Unknown title (Programmer error).”},
    {REC_ENTER_ROOM_CURRENTLY_IN_QUICK_JOIN, “Failed to enter a room. You are currently in quick join. Leave quick join first.”},
    {REC_ENTER_ROOM_CURRENTLY_IN_A_ROOM, “Failed to enter a room. You are already in a room.”},

    3. What used to be function parameters are now structures. Structures have in and out parameters. The same structure is used to send the command, and to notify the user of the result of that command. So the system to a large extent is stateless, because the relevant state data is stored in the packet itself. This is less bandwidth efficient but much easier to use:

    struct System_GetTitleRequiredAge : public Lobby2Message
    {
    __L2_MSG_BASE_IMPL(System_GetTitleRequiredAge)
    virtual bool RequiresAdmin(void) const {return false;}
    virtual bool CancelOnDisconnect(void) const {return true;}
    virtual void Serialize( bool writeToBitstream, bool serializeOutput, RakNet::BitStream *bitStream );
    virtual bool PrevalidateInput(void) {return true;}

    // Input parameters
    RakNet::RakString titleName;

    // Output parameters
    int requiredAge;
    };

    4. Because commands are encapsulated in a single structure, all you have to do to extend the system is write a new command and add that command to the class factory (which is one line of code). You can also override existing commands by passing your own class factory.

    The C++ is essentially done at this point, except for clean-up and documentation. This system is much more complete than the old system:

    1. System_CreateDatabase (Admin command)
    2. System_DestroyDatabase (Admin command)
    3. System_CreateTitle (Admin command)
    4. System_DestroyTitle (Admin command)
    5. System_GetTitleRequiredAge
    6. System_GetTitleBinaryData
    7. System_RegisterProfanity (Admin command)
    8. System_BanUser (Admin command)
    9. System_UnbanUser (Admin command)
    10. CDKey_Add (Admin command)
    11. CDKey_GetStatus (Admin command)
    12. CDKey_Use (Admin command)
    13. CDKey_FlagStolen (Admin command)
    14. Client_Login
    15. Client_Logoff
    16. Client_RegisterAccount
    17. System_SetEmailAddressValidated (Admin command)
    18. Client_ValidateHandle
    19. Client_DeleteAccount
    20. System_PruneAccounts
    21. Client_GetEmailAddress
    22. Client_GetPasswordRecoveryQuestionByHandle
    23. Client_GetPasswordRecoveryAnswerWithQuestion
    24. Client_ChangeHandle
    25. Client_UpdateAccount
    26. Client_StartIgnore
    27. Client_StopIgnore
    28. Client_GetIgnoreList
    29. Friends_SendInvite
    30. Friends_AcceptInvite
    31. Friends_RejectInvite
    32. Friends_GetInvites
    33. Friends_GetStatus
    34. Friends_Remove
    35. RecentUsers_Add
    36. RecentUsers_Get
    37. Emails_Send
    38. Emails_Get
    39. Emails_Delete
    40. Emails_SetStatus
    41. Emails_SetWasRead
    42. Ranking_SubmitMatch
    43. Ranking_GetMatches
    44. Ranking_GetMatchBinaryData
    45. Ranking_GetTotalScore
    46. Ranking_WipeScoresForPlayer
    47. Ranking_WipeMatches
    48. Ranking_PruneMatches
    49. Ranking_UpdateRating
    50. Ranking_WipeRatings
    51. Ranking_GetRating
    52. Clans_Create
    53. Clans_SetProperties
    54. Clans_GetProperties
    55. Clans_SetMyMemberProperties
    56. Clans_GrantLeader
    57. Clans_SetSubleaderStatus
    58. Clans_SetMemberRank
    59. Clans_GetMemberProperties
    60. Clans_ChangeHandle
    61. Clans_Leave
    62. Clans_Get
    63. Clans_SendJoinInvitation
    64. Clans_WithdrawJoinInvitation
    65. Clans_AcceptJoinInvitation
    66. Clans_RejectJoinInvitation
    67. Clans_DownloadInvitationList
    68. Clans_SendJoinRequest
    69. Clans_WithdrawJoinRequest
    70. Clans_AcceptJoinRequest
    71. Clans_RejectJoinRequest
    72. Clans_DownloadRequestList
    73. Clans_KickAndBlacklistUser
    74. Clans_UnblacklistUser
    75. Clans_GetBlacklist
    76. Clans_GetMembers
    77. Clans_CreateBoard
    78. Clans_DestroyBoard
    79. Clans_CreateNewTopic
    80. Clans_ReplyToTopic
    81. Clans_RemovePost
    82. Clans_GetBoards
    83. Clans_GetTopics
    84. Clans_GetPosts
    85. Notification_Client_IgnoreStatus (Admin command)
    86. Notification_Friends_StatusChange (Admin command)
    87. Notification_Friends_ChangedHandle (Admin command)
    88. Notification_Friends_CreatedClan (Admin command)
    89. Notification_Emails_Received (Admin command)
    90. Notification_Clans_GrantLeader (Admin command)
    91. Notification_Clans_SetSubleaderStatus (Admin command)
    92. Notification_Clans_SetMemberRank (Admin command)
    93. Notification_Clans_ChangeHandle (Admin command)
    94. Notification_Clans_Leave (Admin command)
    95. Notification_Clans_PendingJoinStatus (Admin command)
    96. Notification_Clans_NewClanMember (Admin command)
    97. Notification_Clans_KickAndBlacklistUser (Admin command)
    98. Notification_Clans_UnblacklistUser (Admin command)

    Now I’m just waiting for the DB programmer to write all the queries.