Slashdot Mirror


User: tomhudson

tomhudson's activity in the archive.

Stories
0
Comments
14,724
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 14,724

  1. Re:Figures off by a factor of 10 to 100 on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 1

    It's pretty bad when shelling out is quicker by a factor of 10. Running your c app directly in your server instead of as an external cgi means you save even that overhead - so add in another 10x improvement. Run it in a custom server instead of a generic one like apache, and save even more time.

    Unfortunately, that will never happen because most "programmers" can't do anything much beyond memory-managed scripting (which isn't "real programming" - it's scripting - but that's another argument for another day).

  2. Re:php is bad for the environment on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 1
    php only executes one statement at a time. I explain it here. It also has to re-initialize the memory arena for each execution of the script. That also sucks up a lot of time and resources. Also, most people run their servers to kill off a working thread after 500 requests to help reclaim memory leaks. If you code everything in c, you can make sure that there are no memory leaks (run a few million requests and you'll quickly know if you're leaking), so you never have to kill off threads.

    All these mean better performance. WAY better performance.

  3. Re:Figures off by a factor of 10 to 100 on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 1

    one example, parsing out requests formatted in xml, merging up to 120 different bids/prices from a database, etc.

    There's no way a scripting language can ever come within even 10% of a properly written custom c solution. It will simply never happen.

  4. Re:So the bindings make a difference? on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 1

    You're still initializing your interpreter for EACH result set. Once you add an interpreter to the equation, you've already lost the race. With c, you only need a struct with pointers to the variables you actually use - a lot more compact - and since the actual values are not copied into the interpreter and then copied back out of it, then back into it again, then flushed, you save a lot of time AND memory.

    Plus, php deliberately doesn't let you execute multiple statements with one call - anything after the first semicolon is stripped from your query as a "security measure". Same with php and postgresql.

    This is to help prevent sql injection attacks. For example, someone can't put their user name as "joe blow';drop table users';select 'hacked" (notice the embedded single quote before the semicolon) so that "select pw_hash from users where user_name='$username'" doesn't become "select pw_hash from users where user_name='joe blow';drop table users;'select 'hacked';"

    Of course a c program has to do sanity checks on data as well, but it's a lot easier. For example, if you KNOW that you'll never get a response from the end user that's longer than 2k, as soon as you exceed that limit, stop reading from the socket, send a server redirect to goatse.fr, and close the socket. This way, you don't end up with someone doing a DoS on you with multiple loooooooooonnnnngggggggggggggg requests. You can also set it so that if the bytes don't show up within n time, close the socket anyway - so no tarpits.

    Hope this helps :-)

  5. Re:Figures off by a factor of 10 to 100 on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 1

    I'm glad to see you put "high performance" in quotes wrt the STL. The STL is *not* optimal for anything, and especially not for string ops. My own benchmarks showed it to be at least 4 TIMES slower than a custom class. It seems that the thought of writing even a simple container or string class scares the crap out of people nowadays. And $_DIETY forbid that you try to do it with a collection of functions and a few structs in straight c.

    And if you're writing threaded code, you can't really use the stl anyway. (I know, someone's going to mention proprietary versions of the stl that support finer-grained locking primitives, but even that's not anywhere near optimal).

  6. Re:Figures off by a factor of 10 to 100 on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 3, Informative

    Those were actual benchmarks run at peak load for 5-minute periods. sustained rate of over 600,000 queries in 5 minutes, or 2,000 per second (around 2,200 iirc), on absolutely craptastic hardware, against an 8 gig mysql table. Benchmark was by running ab (apache benchmark) against a custom forking server instead of apache, tested with between 100 and 400 simultaneous requests. Threads were never "reaped", always reused, so it was important that there were no memory leaks, but never having to spawn another thread after initial startup also contributed to the difference.

    Contrast to php, where every script has to be loaded, interpreted, then flushed out of the system so it leaves a clean memory footprint for the next script, and where tons of variables that your script may never call have to be initialized each run. Obviously only compiling what you need and loading it once is more efficient :-)

  7. Re:php is bad for the environment on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 1

    Oops - typo: s/fprintf/sprintf/ - sorry for the typo. And no, we never overflowed the buffer - always checked the arguments length before adding more data.

  8. Re:php is bad for the environment on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 2, Interesting

    The biggest bottle neck is probably data access, in which case the language really doesn't make much, if any difference.

    Wrong - the language makes a huge difference. Try using the c api and CLIENT_MULTI_RESULTS and CLIENT_MULTI_STATEMENTS and concatenating 10,000 queries into one request, then using mysql_next_result() to get the next result set (no, not the next row, the next result set - 0 or more rows).

    One connection. Not 10,000. A BIG difference in execution time. Testing showed that the optimum amount of strcat()ed or fsprintf'd queries was between 10,000 and 20,000 on hardware with limited resources (half a gig of ram, single cpu).

    If each page requires 50 hits on the database, you're going to see a big difference.

    Now imagine this on a machine with much more ram and more than one core.

    More reading: http://dev.mysql.com/doc/refman/5.0/en/mysql-next-result.html

  9. Figures off by a factor of 10 to 100 on The Environmental Impact of PHP Compared To C++ On Facebook · · Score: 2, Informative

    My own experience doing server development in c was that it's a minimum of 30:1 (and in in some cases, much greater). Plus the speed differential is huge, and also in favour of c.

    There's a big difference between a couple of hundred requests a second and 6,000 - 10,000.

    Then again, the php code had to be served through apache, while the c code was served directly by a custom server sitting on a separate socket, so there's no telling how much of the overhead was from apache.

    Even the absolute worst-case scenarios were well over 10:1.

  10. Re:Only one sensor? on Best Man Rigs Newlyweds' Bed To Tweet During Sex · · Score: 1

    I'd say shouting "fuck you" is closest to oral sex.

    Don't laugh - I knew a young engaged couple who thought that "oral sex" meant you talked about it or talked dirty.

    That was an awkward conversation, trying to explain oral sex to them while keeping a straight face AND not throwing in a bunch of "honeymoon" jokes.

    Comparable to the time (this decade) when I was trying to explain Godwin's Law to someone, and it was obvious I wasn't getting the concept across - she finally asked "Who's Hitler?" THAT was a real conversation-stopper! Even her hubby went "WTF?!? You don't know who Hitler was? You're kidding, right?" (*mumble* lousy elite private-school education */mumble*).

  11. Re:Don't pay the fee on Verizon Defends Doubling of Early Termination Fee · · Score: 2, Insightful
    Two points:
    1. In many jurisdictions, what the salesperson said is legally binding on the company, even if the actual contract says otherwise;
    2. Back in the day, Borland had a simple license. You don't have to have a license be overly complex if both sides are dealing in good faith.
  12. Re:Only one sensor? on Best Man Rigs Newlyweds' Bed To Tweet During Sex · · Score: 3, Funny

    Third stage kicks in around twelve or fifteen years. That's where you pass each other in the hallway and say "Fuck you!"

    Way to ruin a good punch-line

    You're supposed to say "Hall Sex", and only after you get the "wtf is Hall Sex" look, explain it.

  13. Re:Of course... on Former Congressman Learns About Streisand Effect · · Score: 1

    According to the Wikipedia article, he cosponsored several anti sex offender bills.

    Didn't want the competition?

    Seriously, this is no different from all the other "family values" crowd. Preach against something in public, and do exactly the same thing in private.

  14. Re:idiots who don't know the law on The Trial of Terry Childs Begins · · Score: 1

    You're such a retard. How old are you, 10?

    And no, you won't even get charged with theft for refusing to give the keys to a company van to a drunk boss. Get over it, stupid.

    Wait, so denying the authorized company representative use of the company equipment isn't theft?

    Nope. Go ask any cop. It's not legal to drive drunk, and ANYONE is allowed to intervene to prevent it by, among other means, confiscating their keys. Has nothing to do with being an employee. Same as you can bar the owner of the company from entering areas that by law require a hard hat or other safety equipment if they aren't properly equipped - AND use all necessary force. You won't be found guilty of assault or unlawful restraint - your boss, on the other hand, if he uses force to resist, can be charged with assault.

    BTW - Pics or it didn't happen. There's no way anyone can believe that Peter Watts and his friend, between them, didn't have ONE cell phone with a camera.

  15. Re:All admins on The Trial of Terry Childs Begins · · Score: 1

    Thank you! For once, common sense prevails! (... am I still on slashdot? ... :-)

  16. Re:idiots who don't know the law on The Trial of Terry Childs Begins · · Score: 1

    I've seen several traffic cases where, because it was only one officers' word against a citizen, the citizen won. I've also won against a cop by invoking a constitutional argument that forced the city to rewrite their bylaw (left-hand turn). And another one ($15 parking ticket) where after I won another city had to send crews out to modify almost every parking sign. That's not including my victories in higher courts. After over 1,000 hours in various court cases, I'll stack my win/loss record against any prosecutor or professional lawyer.

    And no, you won't even get charged with theft for refusing to give the keys to a company van to a drunk boss. Get over it, stupid.

  17. Re:As a former hotel employee... on Bed Jumping Banned · · Score: 1

    Good fucking Christ, is that really cmdrtaco?

    It could be worse ... is this CowboyNeal and the slashmobile?

    Natural selection didn't work ... and it's certainly not "Intelligent" design ...

  18. idiots who don't know the law on The Trial of Terry Childs Begins · · Score: 1

    So it's his word against theirs, and the only thing that anyone agrees on is that the boss asked for the van and didn't get it. That's stealing and a violation of policy. Jail for him.

    Can't be jailed based on the "preponderance of the evidence". That's civil, not criminal. Criminal is "beyond a reasonable doubt." So if it's one persons' word against another, all else being equal, a conviction just isn't possible. So kindly FOAD already with your stupid counter-examples. You don't know what you're talking about, and it really shows.

    Then again, you didn't know what "due process" was either in another thread ...

  19. Re:All admins on The Trial of Terry Childs Begins · · Score: 1

    Again, my post, and your full-shit reply ...

    Let's put it into a slightly different scenario. The boss is visibly drunk, and demands the keys to the company van, which you are in charge of. You give them to him. He plows into someone else, killing them. YOU are liable.

    And if you don't hand him the keys, he has you arrested for stealing company property, thrown in jail, and you are fired.

    You don't know wtf you're talking about. Really. You don't. Get over it.

    If you're going to troll, try to do it at least half-way decently, instead of these lame-ass efforts you're putting out.

    BTW - it's still Pics or it didn't happen - Peter Watts is a liar.

  20. Re:All admins on The Trial of Terry Childs Begins · · Score: 1

    Let's put it into a slightly different scenario. The boss is visibly drunk, and demands the keys to the company van, which you are in charge of. You give them to him. He plows into someone else, killing them. YOU are liable.

    And if you don't hand him the keys, he has you arrested for stealing company property, thrown in jail, and you are fired.

    Your statement is so full of crapola it's not a joke. did the doctor smack you on the wrong end when you were born ... because your comment history shows you're brain-damaged in terms of reading comprehension AND logic.

    How has he stolen company property in such a scenario? If it's owned by the company and it stays on company property, it can't be considered stolen in ANY sense of the word. Instead, he's acted in a conservatory manner in preserving company assets.

    The police will never arrest someone for trying to stop a drunk person from driving - you can even use force - just not "unnecessary" force, same as when stopping any other crime.

    BTW - Pics or it didn't happen.

  21. Re:Raises an interesting issue on Busybox Developer Responds To Andersen-SFLC Lawsuits · · Score: 2

    the SFLC sues people and then demands a donation to settle.

    s/SFLC/RIAA/g;

    What's the difference here, except that for a "donation", the donor, not the recipient, pays the taxes ...

  22. Re:All admins on The Trial of Terry Childs Begins · · Score: 2, Interesting

    The courts have held people liable for 3rd party actions in MANY cases. For example, you're the host of a party, and you let guests get good and drunk, and you then let them drive anyway. Or you have a hazard in your house, and a crook breaks in and hurts themselves. Or you're sick and tired of someone siphoning your gas, so you put razor blades around the inside of the filler flap. Or you're in the military and you obey an order that is contrary to military law (in which case, unless you frag the person who gave the order, you're up shit creek either way - either you disobeyed an order, or you obeyed an illegal order. Officers who give illegal orders would tend to darwin themselves).

    Same thing applies in business - bars have been held liable for letting customers get too drunk to drive and not stopping them. The code of ethics for various professional bodies acknowledges that their members have a larger duty to society as a whole, and not just their employers, and that when there's a conflict, it has to be resolved in society's favour. An engineer can't just certify a bridge that is marginal because his boss tells him to,or choose to willfully ignore a dangerous defect in an area not under his or her direct purview.

    Similarly, the courts are now starting to apply a standard of care on the general public - failure to act when you could have prevented harm is now punishable in jurisdictions that have passed "good samaritan" laws. With the protection afforded by these laws, you now have no legal excuse not to help someone in danger who is in need of immediate assistance.

    Search for "failure to render assistance" - it's now a crime in many areas. Just look at how many "failure to render assistance" are listed in this 6-week crime stats report from one town in Texas.

  23. Re:Fired him first? on The Trial of Terry Childs Begins · · Score: 1

    You have no obligations to your former employer from the moment you're fired? Really? So if I have a company car and laptop, and get fired I can then turn around and say "ha, I get to keep the car and laptop!"? I think not.

    Don't laugh - you can. Unjust or constructive dismissal has legal consequences. You'd be surprised what you can negotiate when your boss unjustly totally screws you over.

  24. Re:All admins on The Trial of Terry Childs Begins · · Score: 1

    "I was only following orders" - the Nuremburg Defense - is not a valid defense. You don't give the passwords to an incompetent idiot, because the law will still hold you liable for the damage done.

    Let's put it into a slightly different scenario. The boss is visibly drunk, and demands the keys to the company van, which you are in charge of. You give them to him. He plows into someone else, killing them. YOU are liable.

  25. Re:Mind over Bat? on Scientists Confirm Fast is Best for Band-Aid Removal · · Score: 1

    Well, if they hit you hard enough, you won't feel a thing.