B3: Brain, Business & Body



Menu

Home
News
Code - Personal Mercurial Repo



LyX/LaTeX preamble & if only...

<gloat>If only? If only. What a world. Some secrets and advantages aren't. Eyes wide open. At the end of the day, I'm open for business and quite happy, winner take all.</gloat>

Every so often I end up recreating various PDF options for LyX. Not hard, but a bit irritating. The following snippet is some LaTeX that should be thrown in LyX's "Document Preamble." I can't live without these options. Hope this helps someone else. Enjoy.

\usepackage[pdftitle={Document Title},pdfauthor={First Last},bookmarks, bookmarksopen=true, bookmarksnumbered=true,colorlinks={true},linkcolor=blue]{hyperref}

Firefox 3: Release Day

By any definition, this is a good thing... sucks that they're effectively down, but I'm pleased to see them being crushed with demand.

Mozilla: Crushed by demand

How true is this?

The more believable reason for why bugs take a long time to get fixed.

Software bug fixing explained

gettimeofday(2) == bad; clock_gettime(2) == good.

Finally, a technical post I feel worthy of commenting on.

Performance of my application changes from time(3) to gettimeofday(2). Why?

Joe Open Source Developer

Doh! Really common question and should be an FAQ at this point.... or it is, but an under-published FAQ that only the performance wonks seem to know or run into as an issue. In short, gettimeofday(2) == EBAD && clock_gettime(2) == EGOOD. I think the best discussion on this is PHK's post titled Timers and timing, was: MySQL Performance 6.0rc1. Please read. Essentially, FreeBSD's gettimeofday(2) syscall is monotonic, highly accurate and precise, and Leenox's is not. Therefore, Leenox's gettimeofday(2) syscall is faster and less accurate than FreeBSD's. I happen to agree that gettimeofday(2) should be monotonic and I take issue with Leenox's gettimeofday(2) implementation. Monotonic time keeping requires CPU synchronization (which gettimeofday(2) does under FreeBSD and should be done under all operating systems) and will always be slow as a result. Most applications that do not require precise time synchronization across threads and CPUs should use clock_gettime(2) with a clock_id of CLOCK_REALTIME_FAST. Few applications actually need highly precise, highly accurate, monotonic time measurement and instead can skid by with highly precise, accurate, but non-monotomic time keeping. And now you know.


Updated June 1, 2008 @20:45:00: I wrote a small time micro-benchmarking program (bench_time.c) to test out various time calls. When in doubt, test. Very interesting results.

% ./bench_time 9079882 | sort -rnk1
Timing micro-benchmark.  9079882 syscall iterations.
Avg. us/call    Elapsed     Name
9.322484    84.647053       gettimeofday(2)
8.955324    81.313291       time(3)
8.648315    78.525684       clock_gettime(2/CLOCK_REALTIME)
8.598495    78.073325       clock_gettime(2/CLOCK_MONOTONIC)
0.674194    6.121600        clock_gettime(2/CLOCK_PROF)
0.648083    5.884515        clock_gettime(2/CLOCK_VIRTUAL)
0.330556    3.001412        clock_gettime(2/CLOCK_REALTIME_FAST)
0.306514    2.783111        clock_gettime(2/CLOCK_SECOND)
0.262788    2.386085        clock_gettime(2/CLOCK_MONOTONIC_FAST)
Last value from gettimeofday(2): 1212380080.620649
Last value from time(3): 1212380161
Last value from clock_gettime(2/CLOCK_VIRTUAL): 2.296430000
Last value from clock_gettime(2/CLOCK_SECOND): 1212380338.000000000
Last value from clock_gettime(2/CLOCK_REALTIME_FAST): 1212380243.461081040
Last value from clock_gettime(2/CLOCK_REALTIME): 1212380240.459788612
Last value from clock_gettime(2/CLOCK_PROF): 185.560343000
Last value from clock_gettime(2/CLOCK_MONOTONIC_FAST): 5747219.271879584
Last value from clock_gettime(2/CLOCK_MONOTONIC): 5747216.886509281

Absolutely not what I was expecting, but very interesting none-the-less. clock_gettime(CLOCK_REALTIME_FAST, ...) is most certainly the way to go on FreeBSD. Hopefully this FAQ can be put to rest for a while.

Updated June 2, 2008 @10:45:00: I wrote a small variation to the above program that compares the values returned from the various time calls (bench_clock_realtime.c). On my dev system, CLOCK_REALTIME_FAST updates its values around 600 times a second, which is likely accurate enough for most applications, but may not be in all environments.

% ./bench_clock_realtime 9079882 | sort -rnk1
clock realtime micro-benchmark.  9079882 syscall iterations.
Avg. us/call	Elapsed		Name
9.317078	84.597968	gettimeofday(2)
8.960372	81.359120	time(3)
8.776467	79.689287	clock_gettime(2/CLOCK_REALTIME)
0.332357	3.017763	clock_gettime(2/CLOCK_REALTIME_FAST)
0.311705	2.830246	clock_gettime(2/CLOCK_SECOND)
Value from time(3): 1212427374
Last value from gettimeofday(2): 1212427293.590511	Equal: 0
Last value from clock_gettime(2/CLOCK_SECOND): 1212427460.000000000	Equal: 9079878
Last value from clock_gettime(2/CLOCK_REALTIME_FAST): 1212427457.656410126	Equal: 9078198
Last value from clock_gettime(2/CLOCK_REALTIME): 1212427454.639076390	Equal: 0
% irb
>> tot = 9079882
=> 9079882
>> eq = 9078198
=> 9078198
>> tot - eq
=> 1684
>> time = 3.017763
=> 3.017763
>> (tot - eq) / time
=> 558.029242190324

The Machine is Us/ing Us.

Probably my favorite online video.

Weezer

Excellent satire. Props to all the geeks and nerds that were geeks and nerds before it became chic.

w00t if you appreciate the not so subtle online video references and smiled about it.

SHDH 25...

/images/madbaby.jpg

OMFG, Sun has turned SHDH into a Chuck E. Cheese for blowhard wannabe programmers.... this is Slashdot in real life.

Yours truly, 2008-05-17

Brilliant on Sun's part, it really is, but the event has been ruined for those who don't give two shits about free food, Wii games, or other knickknacks/musings at Sun's EBC. If I had the opportunity to talk with Jonathan Schwartz, I imagine it'd go something along the lines of, "what's it like to manage the expectations of a company that's competing in a shrinking market place and attempting to sell commodity goods?" It may be gruesome in the marketplace for Sun, but watching engineers play Wii in their EBC will certainly solve whatever fundamental problems Sun has, I'm sure of it. Kinda. Ok, kinda not. Brilliant marketing/advertising, however. Life moves on, status quo. Sun's still on a path of self destruction. Roasted dolphin, anyone?

World's coming to an end: Hell froze over...

Let me throw some political commentary out for enjoyment now that it appears Bush has lost what weight he had left and I've had a chance to agree with individuals I historically disagree with. First, the painful statement. I agree with Bush's desire to veto the farm/food bill, yet disagree with Schwarzenegger's plan to either raise sales taxes or to attempt to increase the performance of California's lottery. Despite them both sharing an (R) after their name, I put those two people on opposite sides of the isle. Generally speaking, I think pretty favorably of Schwarzenegger and have less than pleasant thoughts of Bush, but given this week I found myself disagreeing where I normally agree and visa versa.

The Lottery is a tax on people who never took statistics. Having the state's top elected official openly try and promote flawed spending habits isn't a good message to send to the public. Ugh. Dumb, dumb, dumb. The only redeeming thought that I've had is that Schwarzenegger knows he's "selling" lemon asset that won't perform better, in which case it's brilliant. Problem with that being, both the sales tax increase and the lottery target the lower end of the economic spectrum. Doh. Back to thinking it's a bad idea. Were there no alternative ways to help fund the rainy-day fund (a very good idea, however)?

Then, the food/farm bill. Bad, bad, bad, bad, bad... and yet I find myself thinking the same things that Bush is saying (I can't think of more painful words to write). How's this for an idea: Bush should come to California and buy a lottery ticket thereby fulfilling his role as an intelligent role model while he still holds the office of President of the United States of America. After all, this President is largely known for doing and not thinking, so it would seem fitting to have Schwarzenegger give 'ole Bushy a call and say, "can you do me a favor and come buy a lottery ticket on camera?" An uneducated guess on my part suggests that the lottery does better in Red States, which means this photo op would likely poll for a 2-5 point bump to Bush approval rating and would possibly generate new tax revenue. Actually, how cool would it be to see W as the spokesman for the lottery? That would be weapons grade fail and would perfectly suit my image of Bush.

And then, the political highlight of my week. A perfect example of the demon spawn that has taken over AM radio. I give you Kevin James, a new Internet phenomena (at least he'd better be).

The scariest part? I bet this Kevin guy has decent ratings.

Let me half-heartedly examine both sides of Kevin and attempt to defend his actions (and fail, btw). I only remembered Chamberlain's name, not what Chamberlain did (though I'm guaranteed to remember it now). The counter argument, Kevin is a professional (i.e. paid) political disk jockey showing up on a nationally syndicated TV to defend Bush's remarks in a speech that I can only assume he read and thereby would've researched prominent historical references that weren't understood (reasonable care of professional conduct would suggest he would've read it, but clearly I'm ass-u-me'ing a higher degree of professional care and integrity). Yeah, sorry... this Kevin dude is grade A fail.

Disabling Dashboard

Hi, I'm a Mac user and proud of it. For the life of me, I hate Frontrow and Dashboard. How do you disable the Dashboard? Type the following into a terminal prompt.

$ defaults write com.apple.dashboard mcx-disabled -boolean YES

w00t. Very cool. I haven't figured out the Frontrow one yet, but... it's next!

Quote of the day

Surrounding yourself with the best advisors, maintaining those relationships, and then following through with their advice is infinitely harder than finding decent advice and doing what's easy.

Sean Chittenden, 2008-04-18

In case anyone's interested, it's easy to fall in the easy trap. Don't. Period.