Hello everybody!
For those of you following our development, you might have noticed that after our code split there is a new friend in town: libutils.
The aim of libutils is to be a toolbox of commonly used data structures, algorithms and other handy stuff. Historically we had several implementations of some data structures all over our code, so we decided it was time to start putting all together and make sure we always used the same structures.
So far on the data structure side you can find a double linked list, a map, a sequence and a buffer implementation.
Our buffer implementation is a glorified byte array that can grow if needed. This allows us to stop worrying about putting too much into a char array. It also contains a memory cap, so it will stop us if we are using too much memory. On top of that, or technically speak underneath it, it uses implicit sharing and reference counting, so copying it is both extremely fast and economical.
While developing this there was the suggestion of using bstring instead. I looked at bstring and I decided against it for two reasons:
- The development stopped in 2010.
- It does not have reference counting nor implicit sharing.
The first point is the most severe. Many will argue that the library reached a maturity where new releases are rare, however in the case of finding issues with it we need something that will react sooner rather than later.
The second point is less relevant, although in the long run (and with CFEngine that might mean thousands of hours of running time) it shows its value. Being able to get shallow copies of objects is essential to keep our memory requirements low.
On the algorithm side I just finished a proper rfc-compliant IP address parser for both IPV4 and IPV6 addresses. It will show up in our code in the very near future.
We will continue adding more stuff into libutils, next in line is a dedicated list for Buffer so don’t hesitate to comment or request features. And remember, although it is important to have neat data structures and cool algorithms, these are just the tools that we use to write CFEngine so the real benefit of this can be seen in the better performance and quality of our product!