SBCL Solaris/x86 threading

Posted on 2006-04-26 in Lisp
» 8 comments

Over the last few weeks I've been working on adding thread support to the SBCL Solaris/x86 port. Compared to what Cyrus Harmon has been going through with OS X and FreeBSD threads, I've had pretty smooth sailing so far. Only a few annoyances:

  • Some signal handling suckage: you can only queue POSIX real-time signals to a process on Solaris, there's no way to queue them for a specific thread like on Linux.

  • The Solaris API for x86 local descriptor table access is rather disgusting. For example, to find out which LDT indexes are in use, you need to read binary gunk from /proc directly into C structs. Oh, and also to know the magic LDT indexes that the system uses, but which are not listed in the /proc file.

  • It's to be expected that all non-Linux SBCL porters will complain bitterly about gdb being absolutely useless on their platforms. Solaris is no exception here: both threads and signal handling are completely broken, as far as I can tell. But Solaris trumps the others by delivering at least two other debuggers that are also mostly useless (in different ways).

  • Futexes would've been nice...

  • Good Lord, the userland sucks. Do you know how many times a day I type something like "cp foo foo.`date -I`"? More often than I would've thought, before trying to use a system without date -I. At least 90% of my grep invocations seem to use the -r switch, which Solaris grep doesn't support. And where's my ps aux? AARGH! Yes, these are tiny issues with non-standard or obsolete switches, and different versions of the tools could probably be found in /usr/xgrgle5/bin/, or something. Doesn't make it any less annoying.

But I really shouldn't complain too much, since there have been some positive things too.

  • All the sadistic thread tests in the SBCL regression suite have been passing for a couple of weeks now. I've seen none of the kernel panics and mysterious crashes that Cyrus has been having on the other OSs.

  • I've only had one really bizarre OS-related bug so far, and I could solve it by reading the Solaris source code. Also, it turned out to be my fault in the end. (An issue with the semantics of the x86 single-step flag in signal handlers, if you want to know).

  • In contrast to the debugger suckage, it's great to have tracing tools that really work. Like a strace truss (AARGH) that doesn't barf on SIGSEGVs! And the much-hyped dtrace turned out to be pretty useful in figuring out some hairy timing issues.

The main issue that needs to be solved before this work can be merged to HEAD is dealing with releasing the memory allocated for the pthread condition variable / mutex pair that constitutes a lutex. On Linux we don't need to do this thanks to the magic of futexes. This appears to be solved as of 30 minutes ago: I've been writing this post during the agonizingly slow recompiles, and the very latest version is passing all existing tests and not leaking memory. Some further testing and cleanups required, but looking good.

So expect the first non-Linux SBCL port with thread support to land into the CVS soonish. (Probably after Hamburg). Special thanks to:

  • Cyrus for doing the first 20-something commits on the lutex-branch, pre-emptively fixing all kinds of things that I would've run into, probably sooner rather than later.

  • Nathan Froyd for the original lutex implementation. I suspect that we've replaced both the head and the handle by now, but it's still fundamentally the same axe.

  • Tellme for funding the Solaris/SBCL threads work.

Next » ECLM 2006 report (2006-05-03)
Previous » Gee, Sun really gets open source (2006-03-31)

Comments

By Joseph Oswald on 2006-04-26

Does this help at all to support threads on SPARC/Solaris?

By Craig Turner on 2006-04-26

"Good Lord, the userland sucks." Wow - I know how you feel. In fact - looking at your specific command examples - I *so know how you feel* because I used to run into all the same problems with the same tools :) I ran into (in the brick wall sense) Solaris on and off over the course of several years and kept reacting this way. I hated it. Then I got a job using it all the time where there were people around who could give me tips and one day failed to notice that I'd become used to it.

Now that I have my usage sorted, I actually kind of like the feel that the utilities are simple and predictable in Solaris whereas the GNU utilities at times have an air of magic tricks about them and trying to do too much.

There's a bit of cultural weirdness in the Solaris world - I've found Solaris admins tend to be a pain in the ass about things like making vim available, whereas linux admins already have it installed, even within neighbouring admin groups in the same multinational banks.

Regarding your specific issues: if you have the BSD tools installed, you might find /usr/ucb/ps handy. If you don't have it.. I'm not sure how you'd install it. For date, the usage you want is 'date +%Y-%m-%d'.

For recursive grep, use find -type f -exec grep {} \; -print This would have to be the obscure one in the bunch. '-type f' means find files only, otherwise it'll grep over the files and directories and you'll get confusing duplicate results and it'll be slower. The exec thing is just a bit of magic. '{}' inserts the file it's currently iterating over, and the backslash semicolon means "this is the end of the exec block". Make sure there is a space before that backslash or gets weird about it! :) Also, the print says "print out the filename that matched". Just to be even weirder, in your display results, it does the print, after the match. So you'll see the matching lines, and then the filename they're in, which is counter-intuitive as hell until you get used to it. This find command is useful for a hell of a lot more than grep, and once you get used to it you'll probably think in a way so that you instinctively reach for find instead of grep when you need to do something like that. You can also add a parameter for name matching such as "-name '*.java'".

It might be worth moving to these command usages if you can - they all work on linux, and from memory FreeBSD has at least some of the same issues (eg: date, grep not having '-r'). It's odd - working for banks changed several habits I never would have expected. I even use vi mode in the ksh/bash command-line (set -o vi) by preference because that's what the standard was there and I had an opportunity to see how powerful it was and get used to it.

There's no way for me to give an email address here, but if I can help out with more tricks I can be contacted via my blog, http://stable.cowoh.org

By Daniel Pezely on 2006-04-26

On solaris, try: /usr/ucb/ps -aux

(At least it works on older Solaris-- not sure about 10.)

By icarus on 2006-04-26

Using the find which knows POSIX syntax, the following is much faster than starting up a 'grep' for each file.

/usr/5bin/find . -type f -exec grep pattern /dev/null {} +

Interesting the '-I' option to date, I didn't know about it and it is not listed in the help or manual. The source for coreutils-5.94 lists it as Deprecated.

By Juho on 2006-04-27

Joseph: This gets us halfway there. Before thread support on Sparc/Solaris is possible, we'd still need to port the SBCL generational GC to Sparc. This should be easier now that Cyrus has ported it to the PowerPC, but I'm not aware of anyone working on it.

Everyone: Thanks for the tips (especially on the BSD ps). I did, for example, end up using a GNU grep located at /usr/sfw/bin/ggrep.

By golhy on 2008-08-03

123

By Steve on 2008-08-05

find . -type f | xargs grep pattern

is so much better.

By UX-admin on 2010-02-05

For all the Linux whining "me toos" out there, I've come from Solaris userland to spend my days, day, day out on GNU/Linux and it SUCKS ASS.

GNU utilities suck so bad! They're NON STANDARD, DON'T RESPECT OR ADHERE TO ANYTHING, anarchy simply rules the day.

/usr/xpg4/bin POSIX and System V userland KICK ASS. How can you stand that grep -r GARBAGE?

That is NOT how UNIX works - hence GNU stands for "GNU is not UNIX". On UNIX, we DON'T implement tools inside of other tools!

And don't even get me started on "--something" idiocy, that's just HORRIBLE.

Stupid Linux whining, meanwhile your tools are anarchistic, badly-hacked-together GNU JUNK, boy does that piss me off!

Name
Message

As an antispam measure, you need to write a super-secret password below. Today's password is "xyzzy" (without the quotes).

Password

Formatting guidelines for comments: No tags, two newlines can be used for separating paragraphs, http://... is automatically turned into a link.