Core C++ 2019 :: Nimrod Sapir :: High Frequency Trading and Ultra Low Latency development techniques

  Рет қаралды 52,883

CoreCppIL

CoreCppIL

Күн бұрын

Пікірлер: 56
@CTPATEX
@CTPATEX 5 жыл бұрын
43:51 The copy is also extremely incorrect with memcpy if your key/value aren't trivial. For trivial types, replacing copy-constructor body with "= default" should generate the same code.
@MultiNimrods
@MultiNimrods 5 жыл бұрын
You are right about the triviality requirement (I didn't mention it, but I should) - regarding the quick copy: I am talking about copying the entire map, which can be done for this data structure with a single memcpy call (again, for trivial types), which is not the same as calling the copy constructor for each object (even for trivial objects)
@mohammedj2941
@mohammedj2941 3 жыл бұрын
@@MultiNimrods under the assumption of type triviality, doesn't the compiler optimize the individual copies away using memcpy in this case?
@rajatverma3205
@rajatverma3205 3 жыл бұрын
I’m new here. Currently I’m studying about computer architecture before making a HFT low latency software because hardware is important. I know c++, working heavily on that too. How would anyone guide a beginner who wants to contribute in low latency coding ?
@nimrodsapir3256
@nimrodsapir3256 3 жыл бұрын
I would learn as much as possible on advanced C++ features and paradigms (such as CRTP, which is very useful). Understand memory, caching (memory and CPU) branch prediction and efficient memory allocation and pipelining - all of those things become extremely important when writing low latency code
@rajatverma3205
@rajatverma3205 3 жыл бұрын
@@nimrodsapir3256 feel really good that those are the only things I’m focusing on. I learned my basic c++ from “C++ primer plus by Stephen prata” and have an ongoing course on computer architecture. For more advanced c++, I’ll take help from “c++ by Bjarne Stroustrup”.
@LordNezghul
@LordNezghul 5 жыл бұрын
Wouldn't it be better to use custom version of compiler that generates code that warms up your cache instead of constantly fighting with "leaky abstractions"?
@ShalomCraimer
@ShalomCraimer 5 жыл бұрын
Probably not. The extra cost of building your own compiler would exceed the benefit. It would require not merely compiler-oriented programmers, but also that those programmers become highly versed in the CPU-specific optimizations. These sorts of developers are harder to find. More code to maintain, and more developers means higher costs, for a hard-to-measure benefit. Also, this is a good moment to say that I'd love to go further - have a compiler that simulated the internal state of the CPU (which isn't always very well documented) and optimized the uops and evened out the port-pressure (e.g. how to distribute the work among the ALUs in each core). It might be tricky to provide compile-time core-associativity to allow for such optimizations, but it could be done!
@LordNezghul
@LordNezghul 5 жыл бұрын
@@ShalomCraimer I think there is no need for building entirely new compiler from scratch but maybe just few extensions for existing compilers.
@ShalomCraimer
@ShalomCraimer 5 жыл бұрын
@@LordNezghul I *was* only talking about the work of building a new backend for the compiler. The part of the compiler that decides how to convert the IR into the binary (e.g. "x86 bytecode" for the specific x86 CPU you want to optimize for). It's still a non-minor undertaking, not just to do it, but to prove that there is an improvement from the optimizations. Even discovering the optimizations would become a full-time job, especially while trying to keep up with new Intel hardware.
@nimrodsapir3256
@nimrodsapir3256 5 жыл бұрын
Thanks for your comment, and I have to ask - This custom compiler you describe - it will have to detect (at compile time) the flows which are rarely executed, but are business critical (you don't want to just warm up all your code, just those specific flow), which is not something that I think can be deduced automatically. Also, the generated code should run without side-effects, which is a very tricky definition (some counters may be harmless if accessed by the warmup code, while others must be replaced with a mockup). Again, it is very likely I am missing something here...
@MansoorAman
@MansoorAman 3 ай бұрын
@45:20 Of course -march or -mtune will degrade latency performance, they are designed to maximise throughput. SIMD instructions will of course have higher latency than their scalar counterparts.
@denispriyomov6086
@denispriyomov6086 5 жыл бұрын
The 1st video watched in 2x speed, also skipped initial 20 minutes used as cache warming... Should have been applying HFT algos ;)
@cutyboi8630
@cutyboi8630 4 жыл бұрын
hi thanks its a good . i have a question why using cpp instead of using your own os drivers and assembly lang? why using linux kernal and cpp?
@JMRC
@JMRC 3 жыл бұрын
Just a guess, but besides that maintenance will be a nightmare, often compilers are better in optimization than people are when writing in assembly themselves.
@nimrodsapir3256
@nimrodsapir3256 3 жыл бұрын
Just to comment - these days we have the ways to run our logic end to end inside the userspace (we are using specialized network cards and drivers). So as far as the kernel is configured to allocate the resources we need, we do not require to write any kernel code.
@zoasis7805
@zoasis7805 3 жыл бұрын
@@JMRC To add to this - compilers are better at optimising than humans, but you can always look at this disassembly produced from compiled c++ and try add different optimisations that way, much easier to do than write assembly from scratch.
@PerriPaprikash
@PerriPaprikash 3 ай бұрын
There are a lot of invalid suggestions and recommendation in this video.
@blazkowicz666
@blazkowicz666 3 жыл бұрын
Why Cpp over C, if performance is of ultimate importance? Also what about Rust vs Cpp?
@gurugamer8632
@gurugamer8632 2 жыл бұрын
Which programming languages are best to learn today for high frequency trading?
@insafidris2366
@insafidris2366 2 жыл бұрын
c++ for speed, python for ease, but to directly answer, it is c++
@Space_math.engineer
@Space_math.engineer 2 жыл бұрын
C++ but maybe start with python if ur new to programming imo
@draked8953
@draked8953 Жыл бұрын
Rust is gaining big traction rn in more agile firms
@recursion.
@recursion. Жыл бұрын
@@draked8953 Could you name those agile firms? Really curious
@HowDoYouUseSpaceBar
@HowDoYouUseSpaceBar Жыл бұрын
​@@draked8953High Frequency Trading, Low Frequency Development
@paulmccumber9291
@paulmccumber9291 3 жыл бұрын
Why not use an RTOS? Or even bare metal code running application specific code?
@bibekkoirala8802
@bibekkoirala8802 2 жыл бұрын
They use multicore high end state-of-art processors, not microcontrollers
@paulmccumber9291
@paulmccumber9291 2 жыл бұрын
@@bibekkoirala8802 An RTOS runs just fine on a modern Intel space heater. I'm saying you'd have complete control over what is in the ISRs and be better suited to manage latency. Heck you could even write a thread that NEVER leaves context.
@bibekkoirala8802
@bibekkoirala8802 2 жыл бұрын
@@paulmccumber9291 space heater lmaooo. AFAIK they cut down all fluff from linux kernel, modify the networking layers(kernel bypass) and other performance modifications shit. So, they do get RTOS-like benefits from linux, maybe not hard real-time but close. IMO pure RTOS is better suited for something like sampling audio signals in real-time where you don't need networking protocols and shit like that. Just my views, I don't work in audio or HFT.
@joewu7092
@joewu7092 2 жыл бұрын
Indeed, some of the hfts do what you say. the bare metal code, but usually on a SoC (FPGA net stack + FPGA or ARM algo impl depends on the complexity). I think they are just keen on moving the impl/logics to HW as much as possible.
@nimrodsapir3256
@nimrodsapir3256 2 жыл бұрын
Basically, the idea is to bypass the OS services in real-time altogether (ideally, all the memory is pre-allocated, kernel bypass for the networking, and pinned and spinning threads for the real time threads). So the OS scheduling will only handle the administrative tasks of the system. Beyond that, FPGA indeed can give even high performance, but adds a lot of limitations of course
@cortexauth4094
@cortexauth4094 10 ай бұрын
I am surprised that trading volume is just 50% lmaooo
@paulmccumber9291
@paulmccumber9291 3 жыл бұрын
How about C? I love C++ but I feel like C is right next to the hardware.
@personaladdress3539
@personaladdress3539 Жыл бұрын
c dosent have stl and templates
@ghdshds1899
@ghdshds1899 2 ай бұрын
.. They both are? C++ is more or less an extension to C and maintains all original C libraries s
@paulmccumber9291
@paulmccumber9291 2 ай бұрын
@@ghdshds1899 Debug some C++ and watch it bounce up and down V Tables
@paulmccumber9291
@paulmccumber9291 2 ай бұрын
@@ghdshds1899 If you ever debug C++ you spent a lot of time bouncing around v tables. I love C++ but for pure speed, I'd think C would be faster.
@paulmccumber9291
@paulmccumber9291 2 ай бұрын
@@personaladdress3539 I''m not arguing from a language strength standpoint but if pure speed is an issue, C++ spends lots of time in the V tables.
@rickydeldo8596
@rickydeldo8596 3 жыл бұрын
Thx
@turdwarbler
@turdwarbler 3 жыл бұрын
interesting video thanks for making it. One tip, stand still. you shift side to side and as you are on screen its very distracting. :-)
@comitcrafter
@comitcrafter 3 жыл бұрын
Have you ever lectured before ?
@turdwarbler
@turdwarbler 3 жыл бұрын
@@comitcrafter yes I have quite a lot and I have been videoed doing it.
@nimrodsapir3256
@nimrodsapir3256 2 жыл бұрын
Thanks for the tip (really) - this was my first time doing such a long lecture so I was quite nervous...
@kolponajosna
@kolponajosna Ай бұрын
Miller Gary Lee Larry Martin Karen
@totenkopf30
@totenkopf30 4 жыл бұрын
If you don´t speak English, then choose your own language because is very annoying listening to someone trying hard to find the proper words to express himself in a foreign language.
@pcb1962
@pcb1962 4 жыл бұрын
Stupid comment, nothing wrong with his English.
@spicetard249
@spicetard249 4 жыл бұрын
at least he is trying to help others
@totenkopf30
@totenkopf30 4 жыл бұрын
@@spicetard249 Fuck that shit, all we need to do in life is take care of ourselves. I say, if some asshole is wasting his time helping others, just take advantage of him.
@peterhooper2643
@peterhooper2643 3 жыл бұрын
@@totenkopf30 you must be fun at parties
@totenkopf30
@totenkopf30 3 жыл бұрын
@@peterhooper2643 what parties asshole, I fucking hate human beigns
How low can you go? Ultra low latency Java in the real world - Daniel Shaya
55:32
Colorful Pasta Painting for Fun Times! 🍝 🎨
00:29
La La Learn
Рет қаралды 308 МЛН
Não sabe esconder Comida
00:20
DUDU e CAROL
Рет қаралды 61 МЛН
ПРЯМОЙ ЭФИР. Золотой мяч France Football 2024
4:41:06
Will A Basketball Boat Hold My Weight?
00:30
MrBeast
Рет қаралды 137 МЛН
Algorithmic Trading and Machine Learning
54:49
Simons Institute
Рет қаралды 97 М.
CppCast Episode 287: Trading Systems with Carl Cook
57:30
CppCast
Рет қаралды 7 М.
High Frequency Trading
11:03
WEED - Weltwirtschaft, Ökologie & Entwicklung
Рет қаралды 651 М.
Linus Torvalds: Speaks on Hype and the Future of AI
9:02
SavvyNik
Рет қаралды 253 М.
Building Low Latency Trading Systems
48:24
kevgol0
Рет қаралды 69 М.
What is Low Latency C++    Timur Doumler
1:14:42
Using std::cpp
Рет қаралды 6 М.
Interview with former high frequency trader, Dave Lauer
1:03:20
Chat With Traders
Рет қаралды 35 М.
Colorful Pasta Painting for Fun Times! 🍝 🎨
00:29
La La Learn
Рет қаралды 308 МЛН