SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
korbabe
Topic Author
Posts: 71
Joined: July 14th, 2002, 3:00 am

Low Latency C++

June 6th, 2011, 9:23 pm

Hi all,I wanted to know what type of questions/design patterns would one encounter for high frequency trading/low latency.e.g stuff like for market making/prop trading. Does anyone have any good references such a subject like the overhead for mutex/semaphores in Linux.Or any other ideas people might have on the topic that are outside traditional C++ interview type questions?Kind Regards
 
User avatar
ithousekeeper
Posts: 33
Joined: March 28th, 2009, 11:09 pm

Low Latency C++

June 6th, 2011, 10:48 pm

Maybe have a look at lock-free algorithms.I haven't done this (yet), but I know a technologist who developed high frequency / program trading systems - he mentioned this as part of his expertise.
 
User avatar
farmer
Posts: 13472
Joined: December 16th, 2002, 7:09 am

Low Latency C++

June 7th, 2011, 10:49 am

QuoteOriginally posted by: ithousekeeperMaybe have a look at lock-free algorithms.I used to write lock-free algorithms. The difference between that and a mutex is like night and day. I called it a "logical mutex" but I don't remember how I did it. Usually nowadays I just use two 8-bit integers. But like when I have a circular buffer with a writer and a chaser I never use a mutex.
 
User avatar
demha
Posts: 182
Joined: January 27th, 2011, 8:01 pm

Low Latency C++

June 7th, 2011, 11:45 am

Writing lock-free or wait-free algorithms is hard, very hard. There are very few people who understand all the gory details involved. It's extremely easy to get it wrong and you won't know why things keep blowing up. This is certainly not something you can just read up for an interview. No way.
 
User avatar
lexington
Posts: 321
Joined: November 16th, 2008, 5:04 am

Low Latency C++

June 7th, 2011, 11:46 am

QuoteOriginally posted by: korbabeHi all,I wanted to know what type of questions/design patterns would one encounter for high frequency trading/low latency.Kind Regardsif the job involves exchange connectivity then expect some questions on FIX protocol, TCP/IP, asynchronous IO
 
User avatar
farmer
Posts: 13472
Joined: December 16th, 2002, 7:09 am

Low Latency C++

June 7th, 2011, 1:50 pm

QuoteOriginally posted by: demhaWriting lock-free or wait-free algorithms is hard, very hard. There are very few people who understand all the gory details involved.I disagree that you need gory details. It would be helpful to understand at what spots in the code the processor is likely to suspend one task and begin another. But there are ways around needing to know.QuoteOriginally posted by: demhaIt's extremely easy to get it wrong and you won't know why things keep blowing up.Of course you will, you will know exactly why things keep blowing up. And you adjust your code to discover a setup where they don't blow up, by trial and error. The worse problem is when things only blow at random once in every 3 billion loops or something. Then it will look like it works.
 
User avatar
lexington
Posts: 321
Joined: November 16th, 2008, 5:04 am

Low Latency C++

June 7th, 2011, 1:55 pm

QuoteOriginally posted by: demhaWriting lock-free or wait-free algorithms is hard, very hard. There are very few people who understand all the gory details involved. It's extremely easy to get it wrong and you won't know why things keep blowing up. This is certainly not something you can just read up for an interview. No way.It is very hard in C/C++, but not very hard if you are using Java. Java has libraries for lock-free programming. The Art of Multiprocessor Programming
 
User avatar
demha
Posts: 182
Joined: January 27th, 2011, 8:01 pm

Low Latency C++

June 7th, 2011, 2:26 pm

QuoteOriginally posted by: lexingtonJava has libraries for lock-free programming. I wouldn't put it so strongly. It provides useful data structures and other utilities using lock-free/wait-free algorithms. One good example is the ConcurrentHashMap. Understanding that will give a glimpse of what it's like designing these things. Doug Lea has spent a lifetime doing this.
 
User avatar
capafan2
Posts: 924
Joined: June 20th, 2009, 11:26 am

Low Latency C++

June 7th, 2011, 6:58 pm

Java Concurrency In Practice is a very accessible resource. It gives a very good idea on how this things are designed as well as what technical challenges are faced when designing these things.
Last edited by capafan2 on June 6th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
lexington
Posts: 321
Joined: November 16th, 2008, 5:04 am

Low Latency C++

June 7th, 2011, 7:12 pm

QuoteOriginally posted by: capafan2Java Concurrency In Practice is a very accessible resource. It gives a very good idea on how this things are designed as well as what technical challenges are faced when designing these things.It has only one chapter on lock-free programming.(chapter 15)
 
User avatar
capafan2
Posts: 924
Joined: June 20th, 2009, 11:26 am

Low Latency C++

June 7th, 2011, 8:05 pm

QuoteOriginally posted by: lexingtonQuoteOriginally posted by: capafan2Java Concurrency In Practice is a very accessible resource. It gives a very good idea on how this things are designed as well as what technical challenges are faced when designing these things.It has only one chapter on lock-free programming.(chapter 15)The book covers lock-free algorithms in several palces in the book - concept of volatile keyword, Compare and Swap instruction sets, HappensBefore concepts all leading to lockfree algorithms. One chapter deals with it formally, the entire books focusses on high performance concurrent programming which essentially requires as little locking as you need to. The latter needs the use of lock-free methodology to the extent you need to.
 
User avatar
traderjoe1976
Posts: 1544
Joined: May 19th, 2006, 9:50 am

Low Latency C++

June 7th, 2011, 8:06 pm

QuoteOriginally posted by: farmer The worse problem is when things only blow at random once in every 3 billion loops or something. Then it will look like it works.If this happens, it is almost certainly a memory management issue. Someone forgot to deallocate the memory. Not too difficult to fix for someone who is familiar with the system.
 
User avatar
demha
Posts: 182
Joined: January 27th, 2011, 8:01 pm

Low Latency C++

June 7th, 2011, 9:35 pm

QuoteOriginally posted by: traderjoe1976QuoteOriginally posted by: farmer The worse problem is when things only blow at random once in every 3 billion loops or something. Then it will look like it works.If this happens, it is almost certainly a memory management issue. Someone forgot to deallocate the memory. Not too difficult to fix for someone who is familiar with the system.Sorry, but I fail to see the link between a race condition and a memory leak. Besides, in a garbage collected language, you can have this problem, and that's nought to do with the garbage collector not freeing memory!
Last edited by demha on June 6th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 61589
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Low Latency C++

June 7th, 2011, 9:59 pm

QuoteOriginally posted by: traderjoe1976QuoteOriginally posted by: farmer The worse problem is when things only blow at random once in every 3 billion loops or something. Then it will look like it works.If this happens, it is almost certainly a memory management issue. Someone forgot to deallocate the memory. Not too difficult to fix for someone who is familiar with the system.Nope. It is very difficult to reproduce these kinds of errors. It is a system manager's nightmare.It is more likely a race condition or some kind of buffer overflow.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
quantmeh
Posts: 5974
Joined: April 6th, 2007, 1:39 pm

Low Latency C++

June 8th, 2011, 1:50 am

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: traderjoe1976QuoteOriginally posted by: farmer The worse problem is when things only blow at random once in every 3 billion loops or something. Then it will look like it works.If this happens, it is almost certainly a memory management issue. Someone forgot to deallocate the memory. Not too difficult to fix for someone who is familiar with the system.Nope. It is very difficult to reproduce these kinds of errors. It is a system manager's nightmare.once in 3 billion loops would be about 10 times per one portfolio run for me
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On