Wednesday, December 14, 2005

MTRR

Sure, you too! Since Stephan made a BDirectWindow based version of our app_server that directly uses the hardware frame buffer and acceleration features, we noticed that it felt much faster there than on real hardware. How could that be?

The reason is actually very simple. Parts of our rendering pipeline like text output isn't optimized to use 32/64-bit memory access - that means it doesn't make full use of the memory bus. While we'd like to change this for the future, Intel introduced a functionality called write-combining in something like 1998 that is supposed to optimize write access to something like a frame buffer. Instead of directly writing the bytes back to the buffer instantly, the CPU waits until you have written 32 sequential bytes, and then writes them back at once, in a single burst. Enabling write-combining is therefore even a good idea if you already have a optimized your graphics output, although the effect is less noticeable in that case.

This brings us back to MTRR, "memory type range register", just in case you asked whatever that would be :-) Using them, you can specify that the CPU should access a part of memory in a specific way - like write-combining, but there are other options, too. In BeOS and Haiku, they can only be specified in the map_physical_memory() call (via the B_MTR_* flags). Graphics drivers usually try to map their frame buffer in write-combining mode, at least all of ours do that, so they are directly benefiting from the new functionality.

MTRR is a CPU dependent feature that is programmed using the machine state registers. Luckily Intel and AMD uses the exact same mechanism here, and thus, we support it for processors of both vendors. We'll make sure that it is supported for other brands like VIA or Transmeta as well.

Even though the app_server has lots of potential optimizations left, it already feels pretty well now. You can still manage to lock it up, but those problems should go away soon.

6 Comments:

At 12:53 PM, freegiftsforworld said...

nice blog ,well written ,keep blogging

 
At 2:42 PM, jeanmarc said...

we love you Axel, i read your progress daily, well hourly actually :)

 
At 8:43 AM, umccullough said...

I've got a Via C3 machine (on an ECS P6VEM3 motherboard w/SiS chipset)... if anyone needs me to test anything.

 
At 2:12 PM, Axel Dörfler said...

To umccullough: I've implemented MTRR support for that CPU with r15560 - cou ld you please check if it works for you? Also of interest would be the serial debugging output. Thanks! If Haiku doesn't boot anymore, could you try with the previous revision r15559 again?

And thanks for all the nice comments :)

 
At 1:26 AM, timezero said...

Great work! Keep rocking!

 
At 4:35 AM, umccullough said...

Axel:

Sorry, i completely forgot to come back and check the comments after I posted that...

I'll grab a current image and see what happens.

 

Post a Comment

<< Home