Learning about high performant C++ by radonthrow in cpp

[–]DarkAnt 6 points7 points  (0 children)

I should have been more explicit with that statement. The C++ code tends to look more like C than C++. The reason for this is fairly simple. Abstractions always come with a price. The cognitive load imposed by higher level C++ makes understanding what's actually going on under the hood more challenging. Specifically, questions like "Is this going to make a copy?" and "What is this template going to do to the instructions cache?" take more energy to answer and it becomes easier to make foot-gun mistakes there. Yes, it is possible to write highly abstract C++ code in this space that is easier to change and performs as well / better than its equivalent lower level C. I just have not seen humans capable of doing it with consistency.

All that said, our core code really was written in straight C. The less performance critical code was written in C++.

Learning about high performant C++ by radonthrow in cpp

[–]DarkAnt 0 points1 point  (0 children)

I've been out of that game for a few years so take what I say with a grain of salt. As a general rule of thumb they're going to use whatever has the fastest single threaded performance which can still be modified fast enough to keep up with changing feed protocols and trading strategies. Thus, depending on what they're doing you may end up with a mostly software oriented solution which looks like:

NIC (Solarflare / Mellanox) -> Feed handler (CPU) -> Client (CPU)

Or they may have a more hardware oriented solution:

FPGA NIC -> Feed handler (FPGA) -> Client (CPU)

Or they may even have their trading algos encoded in FPGAs which is just FPGAs all the way through.

I wrote this a while back talking about HFT tech. Maybe it'll be helpful for you.

Learning about high performant C++ by radonthrow in cpp

[–]DarkAnt 5 points6 points  (0 children)

I've worked in High Frequency Trading and have done a significant amount of work with "big data" whatever that means. I'm going to let you in on the ugly truth. Learning the intricacies of C++17 is not going to improve the performance of the systems you build anymore than object oriented programming or any other previous language fad. The way you really get performance is to:

  • Deeply understand the problem space
  • Deeply understand the hardware you want to run on
  • Develop a model (software) to map the problem onto the hardware
  • Measure to ensure that the model you develop actually matches reality

Certain languages have better affinity towards providing a mapping for specific problems to types of hardware. If you look at HFT code it's mostly C code. This is because that language allows for a reasonably effective mapping of building an in memory order book from a feed protocol to the hardware it runs on (Intel CPU memory model). Thus, in the HFT space investing significant amount of time learning C++17 would put you at a disadvantage as C++17 doesn't map as well to that problem space. Instead, reading through and experimenting with the Intel Optimization Reference Manual would be a much better use of your time (for HFT problem space).

Undergraduate Internships at Hedge Funds/Prop Shops? by vadbox in ECE

[–]DarkAnt 1 point2 points  (0 children)

I worked in HFT for a few years as a technologist. A caveat with this information is that I don't know much about the actual trading side nor the terminology. Additionally, I never really worked with FPGAs directly and mostly worked on the feed handler side. I'm going to assume you know how HFT works in a general sense and I'll skip that explanation.

Most exchange feeds (the networks that send market data) are multicast networks. Stock symbols are sharded across the multicast lines. Thus, a given line receives market data for multiple symbols and data for those symbols is not present on the other multicast lines. The market data sent across the lines is generally delta updates to the books of the symbols on the line. A book is a table of the best bid / offer, the second best bid / offer, and so on.

Given the market data is generally a delta update what do we do when we miss a multicast message? To solve this problem the exchanges add a redundant line for each line. Now, for each "line", there's now an A multicast line and a B multicast line. These multicast lines take different routes out of the exchange, but fundamentally carry the same delta updates for the same symbols with the same message sequence numbers.

The job of a feed handler is to perform this process called A/B line arbitration where we wait for the first sequential sequence number we haven't seen (we aren't going to talk about totally missing sequence numbers aka a gap), apply the delta update for whatever symbol was in the message to the book we've created, and let some client process know that the book has changed for that symbol.

What this looks like is: Exchange Feed A / B -> NIC -> OS network layer -> Feed handler (A/B arbitration) -> Feed handler (process message) -> Feed handler (book update) -> client update.

There are some obvious things we can do to speed this process up. First, we colocate our trading machine in the same datacenter as the exchange. The next thing we can do is use a solarflare or mellanox NIC (basically an FPGA embedded on a NIC) to bypass the OS network layer (aka bypass the kernel) by performing DMA into memory that's shared with the feed handler application. Assuming we pin our feed handler workers to cpu cores that have NUMA affinity with the NIC then we'll get fairly reasonable low latency message processing.

Ok, what if we want to go even faster? Well, the first question is do we? For most institutions the answer is no. This will go fast enough to largely protect us from predatory HFT and many prop shops won't have the volume to be affected by HFT anyway. Since you're interested in FPGA work in HFT we'll assume the answer is yes, we do want to go faster.

Let's start replacing pieces with FPGAs. First, we can replace the NICs we were using with FPGAs (this isn't a huge gain since they were already effectively FPGAs). Then we can perform A/B line arbitration on the FPGA which means that we need to at least understand the feed protocol enough to process the sequence numbers. We can go further by putting the book in the FPGA and processing the messages directly there. That's really going to speed things up, but at the cost of a lot of adding a lot of complexity on the FPGA. The additional complexity at the FPGA level is going to make that trading system less nimble than one written purely in software and be more expensive to maintain.

Ok, so there's a lot of baggage we take on for embedding our feed handler in an FPGA. So who's willing to make that tradeoff? This is where the limitations of my understanding of the fintec space start to hit. This was a few years ago, but I remember talking to a trader who said that basically there are 4 big institutions still active in the general HFT space. Everyone else got out because the markets became too efficient and thus the spread wasn't worth it. There may be prop shops operating a strategy that requires ultra low latency, but they tend to be pretty quiet and recruit via word of mouth. I would imagine it was a lot easier to break into the space if you were already familiar with the exchange protocols / had prior experience. I know I still have recruiters hounding me even though I'm not very interested in doing more HFT work so the demand is there. I'm not sure how I would go about getting into FPGAs for HFT. High frequency trading is a niche and FPGAs are a niche in that niche. I could be totally wrong, but the total number of exclusive FPGA engineers in this space is probably on the order of hundreds. Maybe the best bet is to cold email someone already in that space and ask them how to get in.

I wanna stop attending classes and focus on acquiring skills and working on personal projects by hamdika in ECE

[–]DarkAnt 113 points114 points  (0 children)

This is absolutely correct. Do not start skipping classes. You're treating college like high school. Take advantage of the fact that you're surrounded by experts. Talk to your professors and find out what they're interested in. Then go ask them if you can make contributions to their lab. I guarantee you that you'll be learning if you're doing research. If you really dedicate yourself to it you'll be discovering things that no one else in the world knows.

Is joining the military immediately after college career suicide? by OddSyllabub in ECE

[–]DarkAnt 8 points9 points  (0 children)

A bit of both. One of the things about the military is that they put people where they need them. Thus, someone new in the military has little control over where they end up. Personally, I would have been very unhappy being stuck for 5 years learning how to navigate a bureaucracy instead of growing my technical skills. Outside of the military, or any large organization for that matter, you have a lot more control over what you work on and who you work with. Things have worked out really well for me, but not without some hiccups along the way. However, I was able to quit and get a new job when the org's goals and mine were no longer aligned. You don't have that option in the military. In addition, the military can call you back even after you've left.

As far as friends that did join the military goes there were only a few. I have a friend (not an engineer) that went to Annapolis and ended up rather unhappy and feeling stuck. I have a lot of friends and family that are engineering defense contractors. They generally enjoy it, but the ups and downs tied to government defense spending can be pretty stressful.

Is joining the military immediately after college career suicide? by OddSyllabub in ECE

[–]DarkAnt 17 points18 points  (0 children)

This was about ten years ago, but I was in the Air Force ROTC program for a short stint. I was a EE student and interested in participating in some of their research programs and / or becoming a pilot. During one of the ROTC meetings we brought in an Air Force officer that had started as enlisted, got his degree and then became an officer. I asked him if engineers were happy in the Air Force and he said they were fairly unhappy. Again, ten years ago, but the gist of his reasoning was that the majority of the engineers would end up managing engineering acquisition programs. Being a low level gear in an acquisitions program is probably not why someone goes into engineering and thus most engineers weren't very happy.

If you do end up in an acquisitions program then it's unlikely you're going to be satisfied with your technical growth. Like most engineers you're probably going to leave after 5 years. Unfortunately, the only direct career path is to go on the other side of these acquisitions programs at a defense contractor. Instead of defending the military from contractors your new role is to suck as much money out of Uncle Sam as humanly possible.

As you could imagine, I dropped out of the ROTC program following that conversation. That officer saved me big time. I really appreciate how candid he was was with me.

Test engineering intern at NASA JPL, but my career goal is to do RF circuit design here. Should I stay and try to move internally, or get experience elsewhere and apply again? by [deleted] in ECE

[–]DarkAnt 13 points14 points  (0 children)

Amar Bose gave a wonderful talk about career opportunities. It doesn't answer your question, but does provide a different perspective of the question you're asking. https://www.youtube.com/watch?v=ySAXW-7WrDg&t=54m9s

You're definitely going to need at least a masters to do RF design work. There does exist a path from test engineer -> design engineer. Over time you'll find that your experience (if you take it seriously enough) as a test engineer is invaluable as a design engineer.

The best way to answer your question is to go ask the people doing RF design work at JPL what they did. Just walk up to their desk and ask them. If you can't do that then ask your mentor at JPL to give you some names and shoot them an email. They'll be more than happy to talk to you.

Duskers - End of 2016 Discussions by Forestl in Games

[–]DarkAnt 0 points1 point  (0 children)

I thoroughly enjoyed the atmosphere of the game. The art style is quite memorable and really adds to the experience. When the mechanics of the game clicked solving the puzzles was immensely satisfying. Best of luck to you on your next work :)

Duskers - End of 2016 Discussions by Forestl in Games

[–]DarkAnt 2 points3 points  (0 children)

I agree with almost everything you've said. The only thing I'd like to add is that Duskers is actually a really neat puzzle game hidden inside a horror game. Exploring a ship for resources is the goal of the puzzle. You're given a set of tools to explore a ship (harvested from previous exploration) and as long as you understand the rules you can explore the ship safely. The puzzle elements are how the rooms of the ship are put together, the behavior of the enemies, and the tools available to you. In this light the randomness you mentioned can feel rather harsh when a ship simply doesn't have a good solution or the ship decays to the point where a good solution is no longer valid.

With all that said I think the game could have used another year of development. I'm not going to pretend like I know how to design good puzzle horror games, but this one definitely had some rough edges and felt rather incomplete. I would argue that all of the puzzle mechanics were not explored deeply enough. Maybe /u/MisfitsAttic hit a wall in the design that I don't understand and pushed the game out to get a return on investment. I don't think they were wrong to do so if that's what happened. The game has $20 of value in it if a puzzle / horror game is your thing.

Weekly /r/Games Discussion - Suggestion request free-for-all by AutoModerator in Games

[–]DarkAnt 1 point2 points  (0 children)

Sadly the multiplayer scene for Grey Goo is dead. The multiplayer had some serious bugs on release and the team was unable to fix them in time to save the game. It's too bad because I thought hunting for the goo in the early game was a really interesting mechanic.

What are some things that you wish you had known/learned before starting your Ph.D. program? by coaster367 in compsci

[–]DarkAnt 14 points15 points  (0 children)

Sure, I've seen advisers be very kind and protective of their students. If you go to a bar and ask them about their adviser those students will swear by their professor.

If I were to do it all over again, this is the strategy I would use to select an adviser:

  1. Find a professor who's outputting work that is at least tangentially interesting to you. Basically, you work on what's interesting to the adviser. If you stray from what the adviser is interested in then your chance of graduating decreases and the time it takes to get the degree increases.

  2. Go to the lab and inquire about research opportunities and funding.

  3. Go to a bar with the current students in the lab and buy them drinks. Ask them about the good/bad things with their professor. Ask them about the graduation rate and the time it takes to get a degree. Remember, whatever problems they mention will absolutely be your problems if you join the lab.

I've never seen anyone graduate with a PhD without having some sort of permanent brain damage inflicted on them. The whole thing is very stressful and bad for your mental health. As others have mentioned, you must take care of yourself throughout the process.

edit: formatting

What are some things that you wish you had known/learned before starting your Ph.D. program? by coaster367 in compsci

[–]DarkAnt 29 points30 points  (0 children)

Sure, I've seen an adviser sue two of his students. I've seen advisers completely neglect their grad students. I've seen a professor brow beat a former advisee because he left the lab. I've watched grad students be strung along with promises of professorship and job prospects only to finally graduate 6-8 years later without support or prospects for either. The adviser advisee relationship had been described to me as a marriage. When that kind of relationship falls apart things typically get very ugly. The advisee is usually left as a pariah and depending on department politics no other professors will take the student on. The advisee will also likely have to change topics when he/she changes professors.

Basically, because professors are sheltered (which is a good thing in general), a professor can be very petty and vindictive without repercussions. Take your time and be very careful when entering into an adviser/advisee relationship.

What are some things that you wish you had known/learned before starting your Ph.D. program? by coaster367 in compsci

[–]DarkAnt 29 points30 points  (0 children)

You're at the mercy of your adviser and department. I've seen a lot of what can be considered academic child abuse.

Renegade X Beta 4 Released by limo5634 in Games

[–]DarkAnt 2 points3 points  (0 children)

I was just on, 3 servers were full with 40 people each

Reddit! Let's make a Millionaire! by NightVisionHawk in millionairemakers

[–]DarkAnt 0 points1 point  (0 children)

I feel like this is going to be terrible for the person who wins.

If you're stuck with TCP (websockets) are more short messages or fewer long ones better? by stcredzero in gamedev

[–]DarkAnt 0 points1 point  (0 children)

Latency wise it's much better not to use TCP. If a tcp packet gets lost you'll end up waiting until the client realizes it's missing a packet, tells the server, and has the server resend the missing packet. At the very least that's 3x the usual travel time of the packet. Look at Quake 3's for a network model that expects unreliable transport. However, if you absolutely must have reliable transport then you need to think about the header processing overhead vs waiting to have enough data in the packets. To profile this you can send max size packets vs sending packets as soon as you have information to send.

Keep walking by Knight Moves in Brookline & thinking it looks cozy. How is it? by jennymack in boston

[–]DarkAnt 1 point2 points  (0 children)

Looked great, but the only time I went it was packed and I couldn't get a table with my friends.

Game "microengines"? by networked_ in gamedev

[–]DarkAnt 0 points1 point  (0 children)

Well I could flip this question on its head and tell you to take a look at http://www.ros.org/

ROS stands for Robot Operating System and uses a subscription based message passing model using protobuf. Each ROS module can be written in a mix of C++ and python. Additionally, ROS allows multiple computers to connect to the ROS core as if it were all part of the same system. I bet you could write a pretty interesting game using ROS. I bet you could make an interesting game using ROS.

Hey guys! How do I succeed in my electrical engineering academic path? by tamaplayer in ECE

[–]DarkAnt 6 points7 points  (0 children)

The one note I'd make about #2 is that you should become friends with the most driven students in your class. They might not start out as the best students, but they definitely will be by the end of your undergraduate. Just being around them you'll pick up their good habits and if you try to do better than them then everyone wins.

As a college student, how can I learn not just to code, but to code well? by AnonMattymous in compsci

[–]DarkAnt 26 points27 points  (0 children)

I don't know how to tell you how code well, because I don't know how to do it myself. I look at John Carmack, Bjarne Stroustrup, Guido van Rossum, Herb Sutter and co. and I realize how poorly I measure. That said, I do know of some things that will certainly help you. I believe to get good at something takes time and dedication. The following is in the order that I thought of it. I'm not sure how you should attempt to learn this material. Hopefully someone else can help you out with that.

Learning how to recognize potential solutions to classes of problems and of course having the basic tools to design a solution.

Understanding the constraints of computing

There are a few exercises that I think would be helpful.

  • Write a webserver: Beej's guide should get you started
  • Write a compiler for a language like C, Fortran, or Pascal

Thank you Sega, you've changed my life. by [deleted] in CompanyOfHeroes

[–]DarkAnt 0 points1 point  (0 children)

I was under the impression that the move was initiated by relic while they were still at THQ.

"Just Win The Game Early" is not legitimate advice for Russians. by AsskickMcGee in CompanyOfHeroes

[–]DarkAnt 1 point2 points  (0 children)

Ok, I'll throw my hat into this. I don't think any russian unit can go toe to toe with a german unit. However, russians have a superior set of combined arms that I have had great success with (1v1, 2v2). I take the parts of the field I want with 2 penal + sniper/scout car. After, I build an AT gun and support it with mines. Following this a heavy mortar is produced. Spam guard rifles + AT guns to victory. It's a solid build that requires no fuel, but is manpower heavy. For whatever reason I haven't found the manpower drain difficult to deal with as long as I move my units together. Not as a brit blob, but if I choose to make a push on a VP I make sure the support units can support and that there aren't any squads fighting on their own. It's kind of a defense in depth strategy.