Posts Tagged ‘BD-things’

Intel Graphic cards, Linux, Xorg and UXA performance boost

Sunday, June 21st, 2009

For people having Intel graphic chipset under Gnu/Linux, performance using 3D applications or Compiz-* window manager effects has always been a problem. Intel drivers for Xorg never gave problems but have also never been brilliant. I always looked around searching for xorg.conf tuning configuration entries.
Today I was simply browsing Ubuntu Wiki and discovered the UxaTesting page. I wanted to know something about UXA and Intel drivers, so I found a Wikipedia definition:

In computing, UXA is the reimplementation of the EXA graphics acceleration architecture of the X.Org Server developed by Intel. Its major difference with EXA is the use of GEM, replacing Translation Table Maps.

Yeah cool, the official Xorg Wiki Intel Graphics Driver page Gives also some more information, so if you've got one of these chipsets (you can verify using lspci | grep VGA ):

  • i810 and variants thereof
  • i815
  • i830M
  • 845G
  • i852GM
  • 855GM
  • 865G
  • 915G and variants (GMA 900)
  • E7221
  • 945G and variants (GMA 950)
  • 946GME
  • G33
  • Q33
  • Q35
  • 965G/Q
  • G35
  • G41
  • G43
  • G/GM/Q45

You may want to try out the new acceleration method by adding this line


Option "AccelMethod" "uxa"

To your /etc/X11/xorg.conf file, in section "Device".

Please note that:

  1. UXA is not yet stable as EXA. Try it out, signal your experience on the Ubuntu wiki page and fill out a bug if necessary
  2. You will need at least Xorg server 1.6.0
  3. You will need at least xf86-video-intel-2.6.2 drivers
  4. I don't think this is mandatory, but please tell me if you encounter differences when updating to 2.6.30.x kernel. I already have 2.6.30.0 on Sid so I don't know if with a previous version this is working

On Debian Sid I just had to add the Option line to my xorg.conf file.
The performance differences are noticeable and incredible. Everything runs faster and smoother.
My glxgears output went from 60 FPS (using EXA) to 425 FPS (using UXA).
This is a 700% performance improvement!

  • Share/Save/Bookmark

Introduction to Aspect-Oriented Programming

Tuesday, June 16th, 2009

Like I did for Functional Programming, this post contains the mindmap that covers the basic elements of Aspect-Oriented Programming.
This is just a tiny summary of the most important points of AOP, and uses AspectJ in the examples.

Topics covered:

  • Definition
  • Response to Object-Oriented crosscutting concerns
  • Aspects
  • Advices
  • Inter-Type Declarations
  • Join Point Model: Join Points, Pointcuts, Advices
  • AspectJ tiny example

You can reach a browsable HTML export of the mindmap
You can download a PNG export of the MindMap.
You can download Freemind sources of the MindMap

  • Share/Save/Bookmark

Introduction to Functional Programming

Tuesday, June 16th, 2009

For the Programming Paradigms course we had to study the concepts of Functional Programming.

So here is my usual mindmap regarding the topic. This is just a summary of the most important concepts of functional programming. It also summarizes the very well-written Functional Programming for the Rest of us publication, and uses its pseudo-Java language.

Topics covered:

  • Definition
  • Basic Units
  • Symbols
  • Concurrency
  • Higher Order Functions
  • Functional Programming and Design Patterns
  • Currying
  • Lazy Evaluation
  • Abstract Control Structures
  • Infinite Data Structures
  • Continuations
  • Pattern Matching

You can reach a browsable HTML export of the mindmap
You can download a PNG export of the mindmap.
You can download FreeMind sources of the mindmap.

  • Share/Save/Bookmark

Finally, the site has entered top 20000 Netcraft Most Visited Web Sites

Tuesday, May 26th, 2009

It is always a great satisfaction to reach a goal. It took me about 3 years but I finally did it!
Today bd-things.net entered top 20k in Netcraft Most Visited Websites, at position 19058!
On September I desired to re-enter top 30k in about a year after the domain name change .
8 months after I reached a even better result.

I took two screenshots of the event , because I don't think that this will happen so much often in my life :)

bd-thingsnet_top_20k_netcraft_2

bd-things_top_20k_netcraft_1

I would like to thank all the visitors of bd-things.net for their support, even if I would be happier to see more comments that would surely help to improve my articles.

In something more than a month I will publish 3 project source codes: a C++ task manager, a simple dynamic website using Java EE5 and a C (subset) compiler. All of them started as University Projects. The first program will surely be expanded and improved after the publish of the source code. But before that time, I have to study hard for ca. 20 deadlines I must accomplish. See you again.

  • Share/Save/Bookmark

A major revision for my publication about Object-Oriented Memory Management

Friday, April 10th, 2009

It took about a year for a major revision of my document about memory management in object oriented programming languages.

This major revision adds C++ in addition to Java.

The paper is about a model for memory management during the execution of programs written in Java and C++.

The number of pages grew from 17 to 28.

You can see more information and download the pdf on this page.

I hope you will find it useful to model your programs and know how memory is handled.

  • Share/Save/Bookmark

Heap vs. Stack in C++

Friday, March 20th, 2009

After the study of pointers versus references, the second natural question that comes in head of a ex Java developer turning to C++ is:

"What are the difference between static and dynamic memory allocation in C++?"

which can be translated as:

"When should I use the stack and when do I have to use the heap in C++?"

that can be further simplified to:

"When should I use the new operator in C++?"

I could simply summarize the answer to: "Use stack when possible", but I think that this time there is the need of more explanations. Let's have the following model for a process in the system:

A simplified model for a process

A simplified model for a process

I'm not really interested in an real representation of a process (see Modern Operating Systems by A. S. Tanenbaum for a very good explanation on processes), but focus on the stack and on the heap.
In reality the heap is a software abstraction but you can also imagine it like the stack.
In C++ programs there are also several other memory areas in which objects and non-object values may be stored (see this article on GotW for further details).

Why then choose between stack or heap? Quoting my publication on object-oriented memory management in Java:

Stack-based variables have their extent determined by their scope, so the former is constrained by the structure of the code at compile-time .

Sometimes there is a need for the variables with unconstrained extent in order to cope with
problems where lifetime of a variable can only be known at run-time.
In this case heap-based variables, whose extent is strictly under control of the programmer, are used. [..]

I promise that I will update my 17 pages about OO-memory management to cover also C++ by the end of June. By the way, following some forums, wikipedia, my publication and GotW, I also summarized pros and cons of stack and heap use in C++:

Stack Heap
Its size is determined at compile-time Size determined at run-time
Therefore, it is less expensive and quick Therefore, it is more expensive and slower than stack
The preferred way to store objects and variables if their size is limited. To be used only if needed: the amount of memory needed is variable and unknown, and may increase rapidly.
There is an AUTOMATIC CLEANUP of objects when they go out of their scope Objects STAY IN MEMORY even when you don't use them anymore.
Programmers don't have to bother to free resources Therefore, programmers HAVE TO CLEAN memory manually. However, all modern OS free the resources when the program exits.

Update 2009-07-03
After 4 months of heavy GUI and Database C++ programming, here are my thoughts: if you are planning to write a program with something more that a couple of objects interacting, using associations and therefore, objects as attributes, use the heap. Every serious program, even if not really big, uses heap for object allocation. Just take care to delete the objects when you don't need them anymore. Objects on the heap are dynamically allocated and it is more comfortable to pass them through other objects using pointers. The use of the heap assures the live of objects even if the method that generated them runs out of scope ( =dies ). If you also plan to write GUIs, solid toolkit like QT recommend the use of heap to create graphical objects.

In some Operating Systems, stack is also very limited while heap is usually not.

Here are listed the sources I used for writing this article:

  • http://www.velocityreviews.com/forums/t278261-stack-vs-heap.html
  • http://www.computing.net/answers/programming/stackheap-c/2293.html
  • http://www.codeguru.com/forum/showthread.php?p=1186307#post1186307
  • http://www.codeguru.com/forum/showthread.php?t=350945
  • http://www.gotw.ca/gotw/009.htm
  • http://en.wikipedia.org/wiki/Process_(computing)#Representation
  • http://bd-things.net/object-oriented-memory-management/

Hope that this article helped you to clearly understand the differences between stack and heap allocation in C++, write me if there are other issues or you need more explanations!

  • Share/Save/Bookmark