Cache – False sharing

As modern CPU shared memory architecture, false sharing is the major performance bottleneck on multi-thread application.
False sharing is caused by sharing the same cache line with multiple thread. In order to avoid this problem, it is important that local thread data should be away enough to data used by another thread.
The best way to achieve this is not to spread out data used by a thread. If all data used by a thread is close enough, processor will try to load them on the same cache line which each thread can localize the memory access on their cache line.

Advertisements
Posted in Performance, Programming | Leave a comment

Cassandra – Evolvement of Cassandra column oriented row

The following blog explain how Cassandra has been improved the column oriented row.

https://www.datastax.com/dev/blog/cql3-for-cassandra-experts

Posted in cassandra, Programming | Leave a comment

Java – Spring to inject multiple service instances having same interface

Create service for multiple name providers

interface NameProvider {
    String name();
}

@Service
public class SomeName implement NameProvider {
    public String name() { return "SomeName"; }
}

@Service
public class AnotherName implement NameProvider {
    public String name() { return "AnotherName"; }
}

NameService class can inject multiple NameProviders with the following constructor injection.

@Service
public class NameService {
    private List<NameProvider> nameProviders;

    NameService(List<NameService> nameProviders) {
        this.nameProviders = nameProviders;
    }
}
Posted in Java, Programming | Leave a comment

Java – Importance of final fields for immutable object

Java will guarantee that all thread will see correct values of final fields that were set by the constructor, regardless of how object is published.

Posted in Java, Programming | Leave a comment

C++17 – Simple and clear view of C++17 features

https://github.com/tvaneerd/cpp17_in_TTs/blob/master/ALL_IN_ONE.md

Posted in C++, Programming | Leave a comment

VC++ – Visual C++ package manager for Windows

https://github.com/Microsoft/vcpkg

Posted in C++, Programming | Leave a comment

FP – Gang of four failed me on designing multi threaded and concurrent enabled software

Modern CPU architecture has been enforcing me to create multi-threaded and concurrent enabled software.

I have been creating multi-thread software with Gang of four design principal but this design principal didn’t show me the best way on creating high scalable software without losing the maintainability and performance.

Gang of four design pattern encourage me to hide details and abstract operations but this created harder problems on dealing with concurrent processing. In order to make a correct software, I had to use the locking API to avoid the race condition and this degraded the performance of application. And hiding details make harder to understand logic. Eventually it decreased the maintainability of software.

However, after understanding the functional programming concepts such as Monoid, Functor, Applicative Functor and Monads, I have started to solve this problem without losing maintainability and performance.

Functional programming don’t hide details of logic instead it encourage to write declarative code on describing logic. This approach improve the maintainability of software. And immutable data structure and Monoid allow to maximize the utilization of multiple cores without worrying about race condition and thread locking.

Posted in Functional Programming, Programming | Leave a comment