When coding the Winforms, WPF, or ASP.Net, we often come across the above mentioned terms. These terms get people confused. When I am using the DexExpress control, I came across another variation which is MVPVM ( Model-View-Presenter-ViewModel ). The goal of this article is to clearly explain the differences between these 3 architectures. Common Elements. First, the let’s define common elements. All 3 of the architectures are designed to separate the view from the model. Model ... [More]
I want to show some important statistics before we start to look at the theory behind the scene. Detailed test results from my own computer Scenario Implementation Run Operations per second Duration (ms) # GC (0-1-2) UniCast1P1C Disruptor 0 11 817 537ops 9040(ms) 0-0-0 UniCast1P1C DisruptorWithAffinity 0 11 728 829ops 9093(ms) 0-0-0 ... [More]
So what possessed CPU designers to cause them to inflict memory barriers on poor unsuspecting SMP software designers? In short, because reordering memory references allows much better performance, and so memory barriers are needed to force ordering in things like synchronization primitives whose correct operation depends on ordered memory references. Getting a more detailed answer to this question requires a good understanding of how CPU caches work, and especially what is required to make c... [More]
I want to change my software architecture to fully use the multi-core of my i5-2500k and be able to process as many messages as possible. Then I came about this disruptor for .net. It uses a lot of no lock code to archieve it performance. However, writing no lock code and cache friendly software is definitely very complicated. Armed with my hardware experience, I start to explore how to make the most out of my computer and how to do this mechanical sympathy thingie. [More]
Most multithreaded programs are full of concurrency bugs (races), to keep such bugs out of the programs, programmers generally use locking protocol. Unfortunately, the locks introduced by this protocol have overhead that can sometimes be an issue, which raises the question of whether it is possible to avoid the overhead of methodically locking and still write correct, multithreaded programs? In some cases you can avoid the locking overhead; however, an improvement in performance comes with tw... [More]
When I was doing optimization of my system, I came across this disruptor pattern and got very interested to implement such architecture in my own software. I would like the system to be very responsive and process a lot of currency pairs at the same time. So here we go, this is a super cool solution. [More]
The C# memory model is a set of rules that describes what kinds of memory-operation reordering are and are not allowed. All programs should be written against the guarantees defined in the specification.
However, even if the compiler and the processor are allowed to reorder memory operations, it doesn’t mean they always do so in practice. Many programs that contain a “bug” according to the abstract C# memory model will still execute correctly on particular hardware running a particular version of the .NET Framework. Notably, the x86 and x64 processors reorder operations only in certain narrow scenarios, and similarly the CLR just-in-time (JIT) compiler doesn’t perform many of the transformations it’s allowed to.
Although the abstract C# memory model is what you should have in mind when writing new code, it can be helpful to understand the actual implementation of the memory model on different architectures, in particular when trying to understand the behavior of existing code. [More]
Linear versus non-linear code Most software engineers are used to programming in a linear manner, at least that is how they are taught when they begin their careers. When a program is written in a linear manner that means the source code will be read somewhat like what the diagram in Figure 1 visualizes. This assumes that we have an order system in place that will help us to fetch a collection of orders from somewhere. Humans are used to reading from top to bottom, even if it starts from left ... [More]
We need a way to figure out when it is a bank holiday for the currency pair we trade. Even thought we have a live feed of important event from some internet source. It is still preferable to know in advance when there will be holidy of some sort as most of the time, the trading volume will be much lighter pre and post those holidays. [More]
We can see from the diagram that USD/RMB has successfully tested the 0.618 of the first advance and heading back up to break the overhead resistance at 6.27 The positive divergence of the indicator is very bullish for the USD and hence very bearish for RMB. I want to do a very rough estimate of the next exchange rate if the overhead resistance is broken (it has a very high chance of breaking) i) 6.10950 + 1.618 * 0.16107 = 6.37 ii) 6.10950 + 0.25657 = 6.366 iii) 6.014 + 1.618 * 0.25657=... [More]