Home > Benchmarks > Case1

HnxGC is 100+ times Faster than .NET CLR

In this section, we will give an example that HnxGC is more than 100 times faster than Microsoft .NET CLR program.

It is a very simple program mainly containing and manipulating a single linked queue. With a pre-existing number of nodes in a single-linked queue, 1000 new nodes are created. For each node created, the node is pushed into the queue from the tail, and a stale node is popped and discarded from the head. Thus the number of live nodes in the program is unchanged. The time elapsed for 1000 object creations and queue operations are recorded and compared.

We attached some data (about 40KB) for each node instead just an empty node, and get a result as follows:

System Time Cost Space Cost
(Peak Memory Usage)
Microsoft .NET CLR 800 ~ 1300 ms 450MB
HnxGC 2 ~ 3 ms 9MB

Click to see the output logs: .NET CLR, HnxGC

In this case, HnxGC program is about 400 times faster than .NET CLR.

This mainly comes from the ability of HnxGC to reclaim non-circular garbage immediately. So it collects unused object sooner than .NET CLR, and maintains less wastes of memory for garbage.

Circular Referenced Objects

Some people may ask, how about if these nodes in this example form a circular reference relationship that reference counting cannot collect?

To answer this question, we made a little modification, let each node references itself in the node constructor routine. This will disable the capability of reference counting technique to collect these nodes. Unreachable nodes will accumulate until it reaches a level and triggers HnxGC system to perform a garbage collection. Here is the result.

System Time Cost Space Cost
(Peak Memory Usage)
HnxGC (Circular Ref) 20 ~ 40 ms 20MB

HnxGC program is about 30~40 times faster than .NET CLR in a circular referenced environment, and just uses about 1/20 of the memory.

Conclusion

The Microsoft .NET garbage collector sometimes may degrade your program's performance so heavily. If your application program might have the same or similar object creation pattern like this example, you must be more careful on choosing a proper automatic memory management system.

download the source code of this testing.
case1-hnx.cpp
case1-clr.cpp
Makefile

See Also:
GCBench, Launch Time of managed programs, Costs of various GC operations, More ...
Download source code of these testings
The hardware and software environment for the testings
Home | Download | Terms of Use | Privacy Statement | Contact Us
Copyright@ 2008 hnxgc.harnixworld.com, All rights reserved.