« May 2003 | Main | July 2003 »

June 2003 Archives

June 10, 2003

Noch ein bischen Werbung bevor es weitergeht

void * and & and C lameness

I don't know who specified it, but that you can't use & on pointers is a major lameness in C.

Especially with addresses you want to mask off bits, and you now always have to cast to an integer and then back again. The problem is though, which integer ? Traditionally on UNIX one used int, but that f.e. never worked well on the Atari ST f.e., where int was defined on some compilers to be 16 bit. With the advent of 64 bit computing, it remains to be seen if all compilers will promote long to 64 bit, so logically one should be using unsigned long long, but that is just horrible :)

One reason, why you may not be able to use & on pointers, might be because you couldn't use AND on address registers on some CPUs like the 680000. but then C was developed for the PDP-11 and I don't know that machine at all.

It is also none none none convenient, that you can't say (void *) p + 12. I suspect some PASCALers were on the committee when this was discussed. :)

[Playing right now: Gasoline from the album "Audioslave" by Audioslave]

Tracer seems to be working. Bugs in Carbon ?

It looks like the tracer is working. I ran a dummy Cocoa application and that worked out OK! I then tried TextEdit.app. It works alright so far, except that the background of the window is brown... Check it out:

I don't know, why that artefact happens. Obviously the different malloc library scheme is tripping something up...

What I did was, I nm'ed all the (Text) symbols in malloc.So in /usr/lib/System.dylib and created a .c file that defines them. I then record anything worthy with my tracer and do the memory management with the brand spankin' new Mullocator (my own mallocer). I couldn't figure out how to use the original code in libSystem.dylib. I tried to create function pointers to the "original" routines, but that didn't work out. It looks like I would have needed to parse the original macho file. That's for another project though...

I then tried to launch Safari and Preview with the tracer lib wedged in. Both failed and crashed. Looking at the crash dumps and at the allocation history though it appears, IF i intercept everything, that there are bugs in those applications, that try to access non allocated memory. But any judgement on this is way premature.

Continue reading "Tracer seems to be working. Bugs in Carbon ?" »

June 11, 2003

Audioslave

The album is pretty routine rock mostly, but the last track The Last Remaining Light is awesome! Sorta like Soundgarden meets Alice in Chains. The first three minutes build up to a final hair raising two minutes, that are worth the € 12 I payed for this alone! One of my favorite track of the year so far.

Ok enough of this boring music shit. :)

Slow Progress and a Wedge Example

Found a bug in valloc, which I just coded yesterday. Still TextEdit.app remains brown. Weird.

OK next up, I might as wll try to reproduce the gawk benchmark using the wedge technique, and I hope that not too much of the 25% gain I had is lost by the shared library call (my original gawk test used static calls).

For the benefit of those, who want to try "Wedging" for themselves, Here is a little test case, a simple example that overrides random.

Continue reading "Slow Progress and a Wedge Example" »

June 12, 2003

Gawk benchmark

I downloaded "gawk" from GNU and build it once just using configure and the standard apple allocator and once I inserted the Mullocator. Then I ran this little benchmark I found somewhere....
# Contributed by Eiso AB <eiso@chem.rug.nl>

BEGIN {
  Switch["123"] = " abc "
  Switch["82"] = " def "
  Switch["985"] = " ghi "
  Switch["20"] = " jkl "
  Switch["1098"] = " mno "
  Switch["3874"] = " pqr "
  Switch["272"] = " stu "

  Switch_R["123"] = " 123 "
  Switch_R["82"] = " 82 "
  Switch_R["985"] = " 985 "
  Switch_R["20"] = " 20 "
  Switch_R["1098"] = " 1098 "
  Switch_R["3874"] = " 3874 "
  Switch_R["272"] = " 272 "

  for (i=0; i <30000; i++)
  {
    s1 = s2 = s3 = " 123 82 985 20 1098 3874 272 "

    for (j in Switch)
    {
      # Manually doing a gsub
      while (match(s1, j))
        s1 = substr(s1, 1, RSTART-1) Switch[j] substr(s1, RSTART+RLENGTH)

      # Use gsub
      gsub(j, Switch[j], s2)

      # gsub, and prevent RE recompile
      gsub(Switch_R[j], Switch[j], s3)
    }
  }
}
Results (before wedging)
bash-2.05a$ 
time ./mullegawk -f bench1.awk 

real    0m16.922s
user    0m14.140s
sys     0m2.480s

bash-2.05a$ time ./applegawk -f bench1.awk 

real    0m22.372s
user    0m19.540s
sys     0m2.310s
Ok now as I had already the mullocator as the malloc library in the MulleMallocTracerLib, I just used the removed all tracing code (with clever use of #ifdef (take that Java)) to get a fairer comparison between the Mullocator and the Apple malloc. I then ran the test again (slightly different, because I need to use a shell script wrapper)
bash-2.05a$ time ./gawk.sh 

real    0m24.526s
user    0m21.810s
sys     0m2.240s
Catastrophe! My code was actually slower than Apple's! Now how could that happen :) ? Fortunuately I had compiled it with -DDEBUG which does lots of checking. With -DDEBUG removed I got
bash-2.05a$ time ./gawk.sh 

real    0m18.709s
user    0m15.290s
sys     0m2.030s
bash-2.05a$ 
This indicates to me, that I am losing a lot time because of the need to bridge into shared library land, which I could avoid before. And also the extraneous wrapping call as f.e. malloc is now coded like this adds to the punishment
void   *malloc( size_t size)
{
   void  *ptr;

   ptr = mulle_malloc( size);
   return( ptr);
}
As I believe that my allocator performs even better when lots of memory is allocated and active, I am looking for some more benchmarks, that stress the memory system even more.

Sweet Success with the Second Benchmark

Wrote a small C program to create a big file of preprocessor commands, like this
#define OVJLAAAA( x, y)   for( x = 0; x < y; x++) /* garbage */
#define PVJLAAAA( x, y)   for( x = 0; x < y; x++) /* garbage */
#define QVJLAAAA( x, y)   for( x = 0; x < y; x++) /* garbage */
#define RVJLAAAA( x, y)   for( x = 0; x < y; x++) /* garbage */
and ran this file through /usr/lib/cpp.
bash-2.05a$ time /usr/bin/cpp < foo.cpp > /dev/null

real    0m8.561s
user    0m6.840s
sys     0m0.920s
now with the wedged in mullocator I got
bash-2.05a$ time ./cpp.sh 

real    0m7.320s
user    0m5.440s
sys     0m0.950s
A speed increase of 20% user time is not too shabby, because cpp oughta to be doing a little something else besides calling malloc :)

June 15, 2003

Performance Problem Detected and Fixed in the Mullocator

The Mullocator was written a bit lazily in a certain area. This has come to bite me now. So I spent the evening rewriting this portion of the routine to get good speed there too. I used the malloc-test.c from Wolfram Gloger. The pleasant result now is:

Apple:

real    0m0.455s
user    0m0.320s
sys     0m0.040s
Mullocator:
real    0m0.460s
user    0m0.280s
sys     0m0.050s
(The user time is of interest). So in that benchmark the win isn't that big. Still I was losing here before.

[Playing right now: By The Pain I See In Others from the album "Deliverance" by Opeth]

June 18, 2003

Rewrote some other old Part of the Mullocator / ImagePrinter

Rewrote some other not too often used, but lamely written piece of the Mullocator. Considering all the #ifdef and comments that have been inserted, the core code is pretty slim. It's like a fluffy kitten, that when hosed down looks just a spiny little rodent :)
Got actually a email request by someone, who wants ImagePrinter converted to Mac OS X. I asked why he didn't just use OmniGraffle. If there's anything ImagePrinter does better, then I will release it (what the hell :))

Statistics wrong in the Mullocator

I have a little statistics gatherer that outputs the following:
malloced bytes    : 82403192
freed bytes       : 86235890
well the program runs OK, but the statistics are wrong. That's so tedious to fix.

June 20, 2003

Tedious Work on the Mullocator

Fixed more little bugs I introduced during the rewrite. Seems to work OK now again. Nothing else new.

June 22, 2003

Problems getting Mullocator to test with TextEdit

I got rid of the brown color, maybe by chance or maybe also because I rewrote my "msize" routine to fight of pointers, that obviously are not in my allocation space. Now I can launch TextEdit.app in pristine white! With lots of debug output spouting out, I was able to make a lot of tweaks to the Mullocator, so that it (should) behave well also in a Desktop application.

Well almost.

The problem is that TextEdit.app is leaking when running with the Mullocator. It know this sounds so wrong :) But I am tracing all the "malloc/realloc/free" calls that are coming in, and I get twice as many "malloc" calls as I get free calls, when TextEdit.app is idling (and the cursor is blinking). So the problem can't be in my code. The problem can't be in TextEdit.app either, because with the normal Apple malloc it doesn't leak. Somehow either some memory is freed behind my back (how ?) or somehow my code induces Carbon/Cocoa to not free as much memory as usually.

This has me stumped at the moment.

June 23, 2003

Nice, my new machine was presented today and

it will be 10 times faster than my current Cube :) In Germany the machine will be available starting August. I am looking forward to it. :)

June 25, 2003

The good times are back,

I thought. But well they are not :) or rather :(

Read this on the extreeemly mild mannered apple developer mailing list, where cotton balls are considered dangerous weapons

On Tuesday, June 24, 2003, at 11:26 AM, some guy wrote:

> When you old guys retire, who is going to take your places?

Some, take a break from computing and educate yourself about the economic and political environment you inhabit. The powers that drive industry today could care less if us old bastards and/or bitches retire, die, or evaporate.

And as for who will be taking our place?

It ain't you.

Other Guy

(names removed to protect the innocent and guilty :)) : Wow an actual flame. My gracious, I think I might faint! Actually that was a very good laugh.

Well, the public apology just came in, which just goes to show, that the dark age we are living in, is anything but far from over.

Domino in Gefahr

Mein Tankwart meinte, daß die einzige brauchbare Eissorte von Langnese, nämlich

aus dem Programm genommen werde. Das grauenhafte Magnum ist nun wirklich kein Ersatz.

Damit verliert mein Körper einen wichtiges Glied aus der Ernäherungskette. Die Zufuhr von Schokolade und Vanille ist erstmal unterbrochen. Mal sehen, wie sich das auswirkt.

Using gcc3 as a benchmark / Kernel Panics

I have no idea, in what way gcc would benefit from a faster malloc. But I'd like to find out. So I downloaded gcc3, configured and compiled it. Problem is, that my old nemesis the NFS crasher, that has haunted me since OpenStep I believe (Rhapsody at the very latest) is still present, albeit very well obscured in Mac OS X 10.2.6. What used to crash me daily, has now happened for the first time in 10 months.

Unfortunately reproducably, so I have to redo everything on my overflowing local disk (500MB left) instead of my network drive (40 GB left).

Here's what the crash looks like, in case you wonder:

Wed Jun 25 22:37:21 2003

panic(cpu 0): nfs: bioread, not dir
Latest stack backtrace for cpu 0:
      Backtrace:
         0x0008581C 0x00085C4C 0x000287B4 0x0016EF44 0x000B08F8 0x000B8B98 0x0020F3CC 0x00092970 
         0x00090009 
Proceeding back via exception chain:
   Exception state (sv=0x18CF7500)
      PC=0x9000B6CC; MSR=0x0000F030; DAR=0x0007E4B0; DSISR=0x40000000; LR=0x0002C6CC; R1=0xBFFFDA80; XC
P=0x00000030 (0xC00 - System call)

Kernel version:
Darwin Kernel Version 6.6:
Thu May  1 21:48:54 PDT 2003; root:xnu/xnu-344.34.obj~1/RELEASE_PPC
and no I don't think it will ever get fixed :)

Mac OS X Server 1.2 gone

I finally decided, that the Mac OS X Server 1.2 partition was NOT going to be used ever again. So by wasting System and other stuff I could free a GB.

This also means a definite end of life of the Sybase Adaptor for Mac OS X Server 1.2. I wonder if anyone cares about that anyway. :)

June 28, 2003

Embarassing newbie coder bug

I wrote some debug routines for the mullocator, to trace down problems I have with some programs. I managed to code this:
memset( block, length - 2 * ALIGNMENT, 0x9B);	/* initalize with some trash */
Ahem!

June 30, 2003

The irony of having to optimize echo

/bin/echo is running too slowly! echo does close to nothing in terms of memory management, this is bad for the mullocator, because I allocate currently about 70 VM pages waiting for the onslaught of malloc calls. As these pages are actually touched, this means that the kernel is zerofilling 280 MB, which does take a perceptible amount of time, in the end echo allocates like this (the + means malloc)
+ 40 
+ 44
+ 8
+ 72
+ 40
+ 40
+ 40
+ 131072 (131072) 
Painfully enough, I can't satisfy the 32 pages request with my already allocated pages, because it is too large (I reserve the 70 pages or so for smaller requests), which means more zerofilling.. I have no idea, why /bin/echo allocates 131072 bytes. Might be fun to look into Darwin for that.

About June 2003

This page contains all entries posted to Nat!'s Web Journal in June 2003. They are listed from oldest to newest.

May 2003 is the previous archive.

July 2003 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34