Binu Jose Philip's Weblog
A rant for good english
I am not a compulsive essay writer. Never got the urge for verbal diarrhea every day around morning or noon or even night. What gets my goat or sheep or the whole flock is, any long standing irritant. The equivalent of Chinese water torture without the water or the Chinese. The water in this case is prose or what passes by with that name and the Chinese is substituted by countless bloggers, article writers and emailers. If I missed your favorite group feel free to add it mentally. But what am I ranting about here? English. Plain, simple English. Something that seems to exist rarely now-a-days. "Whut u doin n d wknd man?" - babbles a friend on email. "That experience was like awesome and stuff, you know?" - guzzles a product reviewer. "Your making no sense!" - exactly! "There are three configuration files are to be modified" - 'are' fetish ;) Having been in this (computer/software) industry for 10 odd years I can read variables of the kind - fls_idl_pkntr - without breaking stride. There is some kind of justification for that; using 'i' and 'foo' and 'retval' too often can be injurious to health. But, I don't see the extra effort of typing "t h e" instead of "d" bringing on RSI or exhausting your alphabet quota for life. An apostrophe isn't a mustn't, it is your choice, you are writing it. Now for the big question. WHY? Why should I get all worked up over this? Tolerance, allowance, extrapolation, experience and mind reading is enough to get through all of the above and more. Then WHY am I getting worked up? I feel insulted. I feel the other person isn't serious about communicating. Heated rinse water from a suitable dish is soup-ish, but is not exactly soup. You wouldn't wear a broad banana leaf to office, though that too is clothing. (okay, I may some day.) Why the difference there? Because you know there is a limit to the deviance expected from a normal human being. Also because you are showing respect to others in the same social/work circle. Why shouldn't communicating in English follow the same principle? To me, reading a well written article or a book or a blog is a joy. I know everyone can't be a Steinbeck or O'Henry or Terry Pratchett. The least you can do is complete your words, use words in the dictionary and use words as they are meant to be used. Not like you know awful stuff like 'like and stuff'. Punctuations aren't very difficult. If in doubt don't use don't - use do not. You're right, using you are is your choice. One of them is less confusing. Spell checking isn't rocket science unless you have the wrong dictionary installed. At least, when you are publishing something to the big wide world, do a spell check. Weather you goat it rite will depend on wot you rot. Read it after the initial spurt of adrenaline that made your start has worn off. Arrgg... now I sound prissy enough to be hated ;) But I'll tell you this. Writing about "how someone else should write" is fraught with danger. I would have to read the above many times to make sure there are no silly grammar mistakes or non-deliberate spelling mistakes or bad language or ... think before you write. I will conclude with a story my father narrates (17 times as of last month ;) ) whenever I deliver a well thought argument point. There was a priest who was well respected in the village. One day, to the horror of the villagers, they found him being dragged through the paddy fields by a buffalo. Apparently the priest's head had got caught between the buffalo's horns. They caught the buffalo and managed to extricate the priest mostly unharmed. The village elder asked: "Priest! What stupidity is this? Couldn't you have thought a bit before doing something like this?" The priest grew angry: "Who told you I didn't think? For the last three weeks I have been watching this buffalo and it's perfectly curved horns. It's after three weeks of deep thought that I decided to put my head between it's horns. Don't you call me stupid!" The moral of the story for me is to not argue with my father. For you it is to do spell check or to think before you write.
Posted at 12:22AM Apr 04, 2007 by binujp in verbal diarrhea |
DTrace provider for Python
Many scripting languages and their uncles (and some aunties) are getting dtrace-able these days. Being a Python believer, the lack of dtrace for Python seemed .. a lack. Either very few Solaris (and other dtrace enabled patform) users like Python or Python is easy enough to debug and tune without needing DTrace ;-) I convinced myself of the need mainly due to needling by colleagues. Perl aficionados, PHP purists, Ruby upstarts and what not. The other factor was the overhead introduced by DTrace when probes are activated and other-wise. It is negligible! We don't pay any tax for having it in there. So why not? Since I hadn't attempted a similar something before nor looked at the insides of an interpreter for geological times, I was apprehensive. After seeing this, I decided Python shouldn't loose any of the possible visibility. I was impeded mainly by Thud! and Ilium. Now that I have finished Olympos I am free to PyDTrace and blog about it. The changes are small, here are the unified diffs. After applying the diffs, give a "--enable-dtrace" to configure. The only two probes available are function 'entry' and function 'exit'. The nice part is, if you feel the need to extend it - say probe every attribute store - it is extremely simple to do. You would need only to modify Python/ceval.c around "STORE_ATTR:" of the interpreter loop and Python/pydtrace.d to add the new probe description. One problem I faced and is still facing is compiling for sparc necessitates using the v7 instruction set, else dtrace fails saying wrong machine class. dtrace expects sparc ELFs to be compiled for v7 looks like. I am on s10 FCS for various reasons and didn't want to ask before trying out the oozing edge builds. I am excluding my idiotic antics because I tried to dtrace scripts launched via '#!/usr/bin/env python' and ended up trying to dtrace the non-existant env process. Here is what is possible with PyDTrace. The file pydtrace.d will tell you the arguments available with each probe.test.py #!/usr/local/bin/python import sys def a(): print "Ah! death. Welcome to thee brother" sys.exit() def b(): print "Where art thou a()?" a() def c(): print "The band of alphabets" b() def main(): c() if __name__ == "__main__": main() test.d #pragma D option quiet python$target::: { printf("%s\n", copyinstr(arg1)); } # dtrace -s test.d -c test.py The band of alphabets Where art thou a()? Ah! death. Welcome to thee brother <module> _get_exports_list _get_exports_list <module> [..snip..] search_function <module> main c b a a b c main <module>Ooh, too much. We don't want trace every library call. Let's take advantage of them being loaded from /usr/local/lib/...somewhere and one of the probe args being the file-name. We'l also use entry and exit probes this time.test.d #pragma D option quiet python$target:::entry /stringof(copyin(arg0, 14)) != "/usr/local/lib"/ { printf("=> %s %s\n", copyinstr(arg1), copyinstr(arg0)); self->traced = 1 } python$target:::exit /self->traced/ { printf("<= %s\n", copyinstr(arg1)); self->traced = 0 } # dtrace -s test.d -c test.py The band of alphabets Where art thou a()? Ah! death. Welcome to thee brother => <module> /home/bp90447/projs/pydtrace/test.py => main /home/bp90447/projs/pydtrace/test.py => c /home/bp90447/projs/pydtrace/test.py => b /home/bp90447/projs/pydtrace/test.py => a /home/bp90447/projs/pydtrace/test.py <= aThat's better. Let's try it on something bigger. I had an SMF dependancy visulization thingy that I blogged about earlier. Let's try timing the functions in there.test.d #pragma D option quiet python$target:::entry /stringof(copyin(arg0, 14)) != "/usr/local/lib"/ { self->ts=timestamp; self->traced = 1; } python$target:::exit /self->traced/ { self->elapsed = timestamp - self->ts; @time[copyinstr(arg1)]=sum(self->elapsed); } # dtrace -s test.d -c ~xxxx/projs/svc-graph/svcgraf.py\ gss Creating service instance for svc:/network/rpc/gss:default ... done. Dependancy chain ... ---------------------------------------- [ metainit ] [ mpxio-upgrade ] [ root manifest-import pfil ] [...snip...] [ multi-user-server dhcp-server ] [ zones ] ---------------------------------------- I had trouble initializing pygtk and/or talking to X. Check if pygtk is available to python and if your DISPLAY variable is set to a sane value get_one_name 21333 get_forward 34416 get_backward 34917 assign_bounds 99251 sort_it_out 336999 [...snip...] find_dependancy_type 1076364984 _compile 1444167386 extract_dependencies 2490782831 getstatusoutput 7284394250Wow! getstatusoutput() is hogging everything. But the 'wow!' is for this working already. As a last demo piece let's see what other arguments the exit probe exposes. From pydtrace.d ... Exit 1. string (file name, f->f_code->co_filename->ob_sval) 2. string (function name, f->f_code->co_name->ob_sval) 3. string (object type string , object->ob_type->tp_name) ... Let's see what "extract_dependencies" returns for this.test.d #pragma D option quiet python$target:::entry /stringof(copyin(arg0, 14)) != "/usr/local/lib"/ { self->ts=timestamp; self->traced = 1; } python$target:::exit /self->traced/ { self->elapsed = timestamp - self->ts; @time[copyinstr(arg1)]=sum(self->elapsed); } python$target:::exit /self->traced && copyinstr(arg1) == "extract_dependencies"/ { @returnvalue[copyinstr(arg2)]=count(); } END { trunc(@time, 10); printf("\nTop functions by time"); printa(@time); printf("\nReturn types for 'extract_dependencies'"); printa(@returnvalue); } # dtrace -s test.d -c ~xxxx/projs/svc-graph/svcgraf.py\ gss Creating service instance for svc:/network/rpc/gss:default ... done. Dependancy chain ... ---------------------------------------- [ metainit ] [ mpxio-upgrade ] [...snip...] [ multi-user-server dhcp-server ] [ zones ] ---------------------------------------- I had trouble initializing pygtk and/or talking to X. Check if pygtk is available to python and if your DISPLAY variable is set to a sane value Top functions by time get 145876010 __len__ 155688505 _compile_charset 192261669 __next 308277021 _parse 481016701 getwidth 631352428 find_dependancy_type 1010549659 _compile 1586552857 extract_dependencies 2606270498 getstatusoutput 7369136837 Return types for 'extract_dependencies' list 39 tuple 39There you have, DyPTrace. Oh! PyDTrace. If I feel the urge and no one else feels it till then, I'l do something more comprehensive and elaborate and functional and intergrated. That must be better than "I don't feel like doing anything more on this now.".
Posted at 08:32PM Nov 06, 2006 by binujp in python |
Sun C style indentation for [X]Emacs cc-mode
Ever since joining Sun a wonderful number of years ago, seven of them,
I have been brainwashing myself to write only C in Sun's C-style. This
post tells part of what I believe in, maybe that also tells you
why I love Python syntax. It was a an uphill struggle because COBOL
from college popped into mind uncomfortably often.
Over the years I have found that, readability of a source base
increases by magnitudes if there is a consistent style followed
throughout. ON code follows Sun-cstyle. Regardless of how much I
hated not being allowed to do my own thing, it is natural now to
expect 4 space intent on a statement continuation and to expect
a 4 space intent to be a continuation.
Being a sideways member of the church of Emacs (XEmacs is what I put
in between keyboard and libraries or syscalls) indentation is a solved
problem for me. Without more verbiage, here it is:
;;
;; Define "sun" mode to get the continuation line indentation
;; proper, ie. sun-like, in cc-mode
;;
(defun c-sun-get-continuation-proper (langelem)
(save-excursion
(goto-char (cdr langelem))
(let ((current-syntax (caar (c-guess-basic-syntax))))
(if (or (eq current-syntax 'statement)
(eq current-syntax 'statement-block-intro))
4 0))))
(c-add-style
"sun"
'((c-basic-offset . 8)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . +)
(substatement-open . 0)
(substatement-label . 0)
(arglist-cont . c-sun-get-continuation-proper)
(arglist-cont-nonempty . c-sun-get-continuation-proper)
(arglist-close . 4)
(arglist-intro . 4)
(statement-cont . 4)
(defun-block-intro . +)
))))
(setq c-default-style '((cc-mode "sun") (java-mode . "java") (other . "gnu")))
;; end "sun" cc-mode stuff
I have corrected this whenever I found an indentation which didn't
match Sun's c-style. Let me know if you decide to use this minor tweak
and finds a problem.
Now for the next problem of correcting c-style errors on an existing
file. elisp to the rescue - autocstyling!. But the code I have isn't
release ready yet. Let me tell you even the hotch-potch job I have now
is extremely usable. Editor wars or IDEs, if a tool for daily use
can't be tweaked and extended programatically - nwat good I say.
Posted at 04:38PM Aug 10, 2006 by binujp in [X]Emacs |
Opening solaris in Sun-IEC
Some time back I was asked to write an article on Sun IECs (India Engineering Center) contributions to Opensolaris. This was to coincide with the first anniversary of the grand unbolting of Solaris. I agreed on the condition that the article be allowed mention of "underwear" and that it will not be a "business" document. This week the clock caught up with me and I realized that this is not going to be published. Why waste perfectly normal alphabets, eh? So here it is...
The code had been compiled, debugged, re-written, re-formatted, cstyled, brought-over, putback-ed, backed-out, thousands of times. The tortures were endless. The spirit of ownership that comes along after submitting the code to all this and more has to be felt to be believed. Functions and files and modules were owned. Thousands of customers depended on it, hundreds of businesses survived on it, many were the developers who adored it, many more were the geeks who swore by it. Over those countless modifications and bug-fixes it had become the best ever OS on the planet. We were proud to own it and be able to do our bit by renaming a variable to make it go faster. And then... we decided to give it away.
At IEC there is a big bunch of fanatics who discuss how cute little threads chase each other between the slabs and magazines and the dispatch queues inside the Kernel. They narrate how the timely tick pokes through the defenses of an on-cpu thread. The magic behind those all powerful probes of DTrace used to expose the innards of the most reticent of programs. How the omni-all root was sliced and diced and shredded into privilege heaven so that one daemon becoming demon will not kill all and take all. All this we used to explain to each other and to curious college kids, Linux fanatics, BSD converts and Windows lovers. We were always silenced when the 2.6 kernel fan cackled ominously and said "Oh yeah! You and which code base? Show the code and speak, people of the Sun." We would mutter 'doubting Thomases' and slink away. And then... we decided to give it away.
Why would anyone want something owned and used? Take used underwear as a case study. It doesn't seem to carry neither weight-age nor demand around here. Arguments about its pliability and comfort doesn't fly. They say it was tailored for the owner. For volunteer day cloth collection, after a great internal struggle, if I take one to them, they say it isn't safe to care at that deep a level. Owners say it is difficult to let go of something which is so close. Other's avoid it altogether to spare themselves the pain of letting go. A few others admire it on someone else's cloth line. Something similar to the underwear is the OS and the code. It sits right on top of the hardware and we all love our OS. Others are free to admire and wish for it, but give it to you I will not. Why would you want my OS which won't fit you or your hardware as it is? And then... we decided to give it away.
Life and work at IEC has changed a lot after "The Great Sharing", when we gave the world that one piece of software that embodied what Sun's software Engineering stood for. Now there are people here who loose their sleep to bring out distros. Minds busy drawing mindmaps till then have designed logos and source browsers. Many who wouldn't dream of sharing their thoughts even about the quality of coffee have blogged with passion about what they did for Solaris on some rainy Wednesday. Mail servers are starting to feel the heat from the various OSUGs sprouting all over India. More than a few colleges around Bangalore are seeing a rise in the open mouth syndrome when told ".. and you can also download the code anytime from opensolaris.org." The guys who are telling them this are roaming the wild country side in search of colleges, while earlier they would be tanning themselves on the glow from the CRT or LCD. Tech-conferences and FOSSs have a new entry and many more entrants, bunches of escaped Solaris fans from IEC trooping after the OpenSolaris banner. Some of them are spending quality fooz-ball and TT (ping-pong) time on being opensolaris advocates.
Admins have more to do, so do facilities and security. Managers show off their laptops running Solaris. OpenSolaris T-shirts are of lower temperature than even volunteer T-shirts. It is suddenly cool to be *in*. Even before when OpenSolaris was launched a year ago, it had lit the fuse under a few IEC-ians. From when the code had to be trawled for the hidden legal trap and the offensive lurking copyright. That was also when Chandan (before he decided to sprout wings) came up with the logo. It spawned coffee table discussions on the true Sanskrit translation of "open". It went on for hours and spanned the seven eves to surviving the next ice age. The point was we wanted open as in "opensolaris" and not "free" as in disease. Then again Chandan demo'd the prototype of opengrok. Many were sad to see the beloved, ancient, hated and loved cscope stutter before it's new-age competitor.
Discussions on what to blog on and secret pacts of the kind "if you blog this I'l blog that and buy you Samosa" could be overheard. That excitement has carried itself all through last year and doesn't show any signs of abating. We have Moinak who achieved enlightenment via the light of Belenix that shone forth from the Opening of Solaris. Venky started muttering UG UG UG .. in his sleep not long after. The forming of BOSUG solved that. He doesn't sleep anymore. "Only three names yet?" you say! Those are the unlucky few. Now you'l go and search for their blogs and ask them why you did this and why you didn't do that and what is the meaning of all this. Those others who I didn't mention will continue their guerrilla war and evangelisation unhindered.
Tens of universities they visited last year, thousands of CDs of Belenix and Solaris Express they distributed, tens of Tech-Conferences they attended and presented on Solaris. OSUGs have started sprouting in a per-state basis and their strength is growing rapidly. Hundreds of laptops they installed with Solaris, hundreds of home machines now run Solaris because of them. They are the ones driving IEC into the era of Sun and Sharing. They are the ones that bring OpenSolaris alive in India and light the flame to love the best OS the planet has yet seen. I bow to them, them who raised OpenSolaris high and promises us more as the future creeps all over us.
Posted at 04:40PM Jul 13, 2006 by binujp in Paperclip |
Drawingarea full of lines
That title-ar aberration was me trying to rhyme with my previous blog entry title. But the title does say I did what I threatened to do last time. I wrote that python thingy to draw me the dependencies of an SMF service. The result is literally a rectangle full of lines as you can see with rpc/bind's dependencies.
I spend considerable time thinking with the belief that my way of representation was the bottleneck in not getting a simple enough display. Now I think different. In most cases, SMF dependencies are too complex to grok with a few pictures. It is not much use trying to hide that complexity under different kinds of facades. The trigger point for me trying to write this was the trouble my team, Suncluster, had in adding anything new to SMF. Now I think I have proved GUI-ically that it was complexity and not lack of application that caused all those problems. Now I can go back to PxFS and it's magic in making UFS a global file system.
If you got interested in what went into drawing those line, here is the code. You'l need python,pygtk and pexpect. The code is in these two files, svcgraf.py and svcgtk.py. The main program is svcgraf.py, which I ran as "svcgraf.py bind" to generate what I linked to above. Although the results are frustrating I am satisfied about proving to myself that python rocks; in this case because it allowed me to abuse it's ease of use by allowing me to not design but just implement :-)
Now, the time has come for me to watch the samba boys do their thing - 12.30 IST. Writing this kept me awake till now, that is the best thing any blog has done to me ... barring this..
More on why that later.
Posted at 12:42AM Jun 14, 2006 by binujp in python |
Hatfull of Sky
Finished reading Terry Pratchett's "Hatful of Sky". Laughed enough, felt the familiar feel good stretch after I put it down. Although I have to admit, this time I didn't read it in the usual "deeep breath, until finish do I sit here" style. My daughter (4 months) takes prime spot. Most of it was read in the loo and part of the rest with her sitting on the book or by reading to her. The reading was interspersed with my evil cackles which interested her far more than the story line.
This book again has the "Edge Witch" or the "When push comes to shove" problem. A real witch has to work on the edge of things and incidents, and a real witch has to take a decision whether others like it or not. Do we have it in us to make the correct decision and not the nice decision? After finishing the book I took some decisions which only time will tell whether they were correct or just nice. Putting it that way, I would have taken decisions even if I didn't read the book ;-)
I am now trying to get pygtk to display SMF dependencies of a given service properly. When I started of, I had decided on a minimal ascii only display. I thought that the real problem is in extracting the dependency, not in displaying it. After watching screen-fulls of ascii tree scroll by I concluded that a good output is part of the problem and not just extracting dependancies. I have done something I don't like here, calling "svcs -abcdef...." to get me what I want. I hate it when child processes dangle at the end of a pipe. The correct approach would be to write a python binding for libscf (yup not libsmf!) and get myself a progasm. But with python it is all so painless, I end up not designing enough. That is Bad. I won't blame Python for that either.
Posted at 04:03PM Apr 12, 2006 by binujp in Paperclip |
What should I think?
After arguing and shouting against blogs and against letting the world knowing all your thoughts in general, I decided to blog. The only other decision I have to make now is what to put down in words. Earlier I had considered writing about every book I finish as it is finished. The only book I have managed to read recently was Nightwatch by Terry Pratchet. Then ofcourse there was the nth pass through one or the other of the calvin and hobbes collection. But that can wait. To be true to myself, I haven't had many decent thoughts recently. Wait. I have been thinking that a non-scalable, no more than 4 or 2 cpus, version of Solaris may make sense. Why have interrupts sleeping and cpus dispatching left and right when it is running JDS or as a regular desktop? Do we want the many many ignorable overheads meant for Big Iron debugging pushed into every machine we ship? Will that make a difference with CMT? Now that I have said this, my big thought for the day is done. Whoooo .. relief. And I'l write that truss comparison script this week - in Python ofcourse :)
Posted at 12:36PM Sep 01, 2004 by binujp in Paperclip |
Today's Page Hits: 9
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
| Today | ||||||