Archive for the ‘Cube Life’ Category

When Getting “Help” is the Last Thing I Need

Monday, February 7th, 2011

I've written a replacement to an exchange data feed and now I'm trying to work with a few groups to see if it'll work for them. The original intention was not to include them, so if it works for them, so much the better. Still, I've expected more than a little resistance because these are developers that have clearly stated that they do not want this new exchange feed - that the one they have is just fine, thank you. I understand their position - I'm new, they don't want to change. They fear what might happen, so it's easiest to simply drag their feet or poke holes in the project to say why they can't use it.

This is easily solved in one of three ways: fire people, force people, or give up. I'm not in a position to do any of these, but if I had my choice, I think I'd favor the ultimatum angle: force, then fire. This industry is paid far too well to put up with unnecessary crud from prima donnas thinking they know better.

Be that as it may... something struck me as quite odd, and made me lean towards the "firing" angle for one developer when he mentioned today that he took my code, replaced spinlocks with pthread locks and saw an amazing jump in performance. That makes no sense, as I moved from pthreads to spinlocks long ago for this exact reason. Still, I was willing to say I'd try it.

And I did.

Amazing. I got literally thousands of messages a second less using pthreads than using spinlocks - exactly what I expected. So much for the brilliant developer that thinks he's found the silver bullet to all problems.

Yup. For that developer, I'd give them a nice severance bonus and show them the door. Being reluctant is one thing. Being a bad developer is another.

Slick Infix to Prefix Algorithm

Friday, February 4th, 2011

I've been slugging out this idea of infix to prefix conversion and this afternoon I finally cracked it. Well, to be fair, I cracked it on paper this morning and I got it all coded up this afternoon. This comes about because the lisp-like language that I put together for a project at The Shop would require that all arithmetic expressions be written in prefix. Seems obvious, but a lot of the users weren't really excited about the difficulties in putting together prefix expressions.

They seem to be pretty content to say:

  (and (condition 1)
       (condition 2)
       (condition 3))

as they like the short-hand it gives them, but when they need to do something with more than simple addition, like, say the quadratic equation, then things get a little more difficult, and they start to get confused:

  (set a 1)
  (set b -7)
  (set c 12)
  (set x1 (/ (+ (-b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)))
  (set x2 (/ (- (-b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)))

and while I can agree it's not trivial, the infix representation isn't all that easy, either:

  (set x1 (/ ((-b) + (sqrt (b * b - 4 * a * c)))/(2 * a)))
  (set x2 (/ ((-b) - (sqrt (b * b - 4 * a * c)))/(2 * a)))

But they wanted infix in their math expressions. But not pure infix - just selective infix to make decoding as hard as possible. In short, any expression (a section of code enclosed in parentheses) can be either prefix or infix, and it's up to the script parser to figure out which it is, and act accordingly.

Oh... and they also didn't like the required spaces.

This lead to something like this:

  (set x1 (/ ((-b) + (sqrt (b*b - 4*a*c))) (* 2 a)))
  (set x2 (/ ((-b) - (sqrt (b*b - 4*a*c))) (* 2 a)))

where there is infix in parts and prefix in other parts. Not ideal, to be sure, but it's the users that want this, so we need to find some way to make it happen.

Getting the Easy Stuff First

The easy stuff was missing spaces and operator ordering. The missing spaces simply meant that I had to have foreknowledge of the different operators that I could run into, and use them as separators. Not hard, but it was more time-consuming on the parsing, and made the code quite a bit uglier. Still, it was easy to make:

  (*5 2)

return 10.

The next easy one was the operator order. If you have:

  (10 = (* 5 2))

it's easy to see that the first token is not an operator, and to put the first token as the first argument to the expression. When you hit the second argument, it is an operator, and can be put in that place in the expression. In fact, it's easy to say:

  (10 5 3 2 1 *)

as there's only one operator in the mix.

Only slightly harder is to ignore duplicated operators:

  (10 + 5 + 3 + 2 + 1)

for I can look at the first operator for the expression, and if the next operator in the expression is the same, I just ignore it. We're getting pretty far, actually.

The last easy one was putting expressions before operators, but I already had that with the numbers before operators, so we get for free:

  ((5*2) = (2+2+2+2+2))

Now for the Hard Stuff

In truth, all that stuff only took me about an hour to figure out. The hard part is operator precedence. I struggled with operator precedence for several days until I happened to some across an idea stewing in my head. The basic problem is that I did not want to have a multi-pass parser where the first pass tokenizes the expression, the next orders the tokens based on their operator precedence, the next creates the prefix mode, the next makes the evaluation tree, etc. It's not hard to see that a multi-pass parser is a very good way to go, but I'd already put so much effort into my parser (it's a single-pass), that I didn't want to throw all that away if I didn't have to.

All I needed was to come up with a way to handle the operator precedence and I was golden. But it was a pain to come up with. In the end, I had something that worked, and it seemed to be pretty solid. I had a stack of expressions I was parsing into. I started with the top-level expression, and then when I hit a different operator of greater precedence, you pull the last argument off the expression, make a new expression, and put the new operator and argument in the new expression.

It's not really easy to see, and I'm not convinced that it's any really easier than a multi-pass parser, but it works. The reverse is to see the different, looser-binding operator, and enclose the expression in another expression and use the looser operator as the new 'main' operator. Again, not easy to see, but it's working and that's what really matters.

I'm ready to get on to something else.

Under Water with Reluctant Users and Infix Syntax (cont.)

Thursday, February 3rd, 2011

Today was a nasty nightmarish continuation of yesterday. I got a lot of stuff done, but I felt I was always a set behind. It'll change, I know, but while I'm in this "plate catching" phase it's not nearly as fun as it has been... or could be... or will be.

Under Water with Reluctant Users and Infix Syntax

Wednesday, February 2nd, 2011

Today I was totally under water with trying to get some reluctant developers using my exchange feeds and trying to get a new feature into my lisp-like parser: infix notation. I spent all day on these things and never had time to come up for air.

What a day.

A Plethora of Rock Stars – Save Me!

Thursday, January 27th, 2011

cubeLifeView.gif

Everyone wants to think that their work is really special. That theirs is the work that's really clever, or complete, or accurate. I'm sure it all stems from everyone wanting to think that they are special. But we all know that's not really the case. Oh sure... we're all unique individuals, and we all have our assets and weaknesses, but it seems that in the last few years I'm running into more and more folks that just believe - without question, it seems, that they are indeed The One.

It's the Rock Star mentality that seems we're getting more and more inundated with lately. Maybe it's TV and everyone thinking "Hey, if they put that on TV - I can be a TV star!" Who knows, but it's really something I could do without.

Today I've been dealing with some folks on an issue at The Shop, and it's just amazing the attitude I'm seeing. I was asked to deliver a product, I did. They were asked to use it, and they come back with all these measurements of the difference in their version and mine. Yup, there are differences - by design. But it's so passive-agressive to take all this time and bring up all these differences when what they want to say is "I don't want to use it". Problem there is that it's not their choice.

So we get into this very lame discussion about why theirs is better, but it misses the point that management, for better or worse, has listened to the arguments and made a decision. Personally, I don't care if they use my stuff or not. But management cares. Why they are arguing with me (in the passive-agressive way), I do not know. They seem to think I'll back off and go away.

Again... I don't care. Use it or not, it's up to you. But if management asks why you haven't, don't be surprised if they don't like your answer.

I'm floored by these types of people. It's like they believe it's their decision to make. Amazing. Not their company, but it's their decision. Wow.

Properly Mapping the Service Coverage for OPRA

Thursday, January 27th, 2011

WallStreet.jpg

I finally got my hands on the coverage map for the existing 24 OPRA channels - the option data feed from SIAC. It's nice in that I can now exactly map my ticker plants to the symbol ranges they cover. Prior to this, I was guessing, and to cover myself, I was making sure there was lots of overlap. Now it's tight, and focused. Very nice improvement.

At the same time, I worked up the mappings when they go to the new 48 channel distribution in a few months. For me, it'll be just a few changes and I'll be up to date with the new 48.

Just nice to get this out of the way.

Doing a Little Work Debugging ZeroMQ

Thursday, January 27th, 2011

ZeroMQ

I got a response from Steve on the ZeroMQ mailing list about my problems with the latest clone of the github repo. My initial email wasn't very solid, and I've learned a lot sense then, so I made a very nice, detailed response - with line numbers and logic flow, so that he can see the problem I've run into and hopefully come up with a solution.

We'll see in a bit, but for now, it's nice that we have a fall-back tarball that I kept. It's working fine on CentOS 5 and Ubuntu 10.04.1.

Starting to Learn Erlang – Get it Installed on Mac OS X

Thursday, January 27th, 2011

erlang

Well... I'm off on a new path - learning erlang. I have to admit I'm very interested. It's got everything I don't have in C++ - functional programming, easy threading, concurrency without hassles... it certainly looks to be a growth experience. I'm looking forward to it.

I need to learn this for a project here at The Shop, and it's good to be working with a good erlang developer to help me figure things out.

The first thing was to get it installed on my MacBook Pro. There's a site that makes it pretty easy, as if it isn't already pretty easy:

  cd otp_src_R14B01
  ./configure --enable-hipe
  make
  sudo make install

but there is one interesting limitation at this point: you can build it 64-bit on Darwin, but then you can't use the wxWindows graphics. I chose to use the graphics and stay 32-bit. Seems like a decent trade-off for now. Hopefully they will get this fixed in a future release, but then again, who knows.

Added More Fault Tolerance to Ticker Plants

Wednesday, January 26th, 2011

This afternoon I've been working on adding a bunch more fault tolerance to my ticker plants. I had a problem one time with the SIAC symbol mapping data coming out of the configuration service. It should have been a simple JSON map with strings for keys and values, but for some reason, one of the elements wasn't a string. Exception.

So I added in the test for the data types and if they aren't strings, I log it and move on. Had another one where the configuration service didn't return sufficient data for properly configuring a UDP receiver. It then got stuck in a very tight loop that logged a message saying it was retrying, and soon filled up the disk!

That one took a little more effort, but it's all about checking and re-checking to make sure that things are self-consistent. It's not rocket science, but it's hard to predict these problems, and that's why I like to just watch the application run and see what the real world has to offer in terms of problems.

Finally, I added one nice thing to my lisp-like parser. The java version has the functions cond and merge that offer conditional behavior like an if/then but a little more flexible. The cond takes pairs of arguments organized as a predicate and an action. The evaluation of the cond starts with the first predicate - if it evaluates to true then the corresponding action is evaluated and that is the return value for the cond. It's a simple switch statement.

The merge is like an OR union. Every predicate is evaluated, and if it evaluates to true, the corresponding action is OR-ed with the result of the merge. This is more like a filter.

Both are interesting and I really enjoyed adding them to the parser. Now I just need to get to the project where this parser is going to be used.

Lots of Progress Today – Baby Steps to a Great Ticker Plant

Tuesday, January 25th, 2011

Today I've had the opportunity to do a lot of little things on the codebase. The IRC client wasn't splitting lines right, there were a lot more efficient ways of querying out the messages from the QuickCache, client constructors needed a little work - all stuff that wasn't big, but it was important. I was humming right along with the changes - tacking one problem after another.

Pretty nice day. Lots of really useful stuff done.