Visual Basic .NET Performance for Millisecond Order Processing
Summary
The document asks whether Visual Basic can handle an order-routing calculation budget of about one millisecond, with much greater time expected for communication to and from exchanges. The replies distinguish modern Visual Basic .NET from older Visual Basic and VBA, and say its execution speed can be comparable to Java and, in suitable cases, native languages. They recommend keeping the application running, avoiding repeated large memory allocations that can trigger garbage collection delays, using optimized numerical libraries where appropriate, and profiling a representative implementation.
The evidence is qualitative: respondents draw on the shared just-in-time compilation model of .NET and Java, and one reports frequent use. No benchmark or measured order-routing result is provided. The practical answer is therefore conditional: language choice alone does not establish whether a particular algorithm meets a strict latency target. The advice applies to computational time, while exchange and network delays are separate parts of the overall order path; the document does not assess those systems or provide a complete latency analysis.
Key ideas
- Modern Visual Basic .NET can have execution performance comparable to Java for many workloads.
- Avoid repeatedly allocating large arrays because garbage collection can add latency.
- Keep a managed application running to avoid paying startup costs for each request.
- Profile representative computations to determine whether they meet the target latency.
- Network and exchange delays are distinct from the time spent on local calculations.
Tags
Full text
# Is Visual Basic a fast enough for millisecond orders # Is Visual Basic a fast enough for millisecond orders I have an API that for an order routing platform that is in visual basic. The maximum frequency or orders to exchanges will be milliseconds, where the underlying systems are expected to be able to process a maximum of 1 order per millisecond. Generally I would like to write in C++ or Java when I have this level of speed in mind, and have a broad stigma against visual basic for being inherently slower. But since 1 millisecond is a long time in computer time, is visual basic still fast enough? The algorithm will be reading information from the exchanges, crunching a few numbers and determining an order to send back to the exchanges. I am estimating latency of 120 milliseconds, 1 millisecond to do the computational math, and then another 120 milliseconds back to the exchange. or less of course, but I know where the computers are geographically and this is about how long it should take. I would like to keep the computational time at 1 millisecond, this isn't really a stretch for visual basic on a modern computer correct? (the local machine won't be doing much processing, as it will be fed most relevant data from the clearing firms data feeds) ## Answer by user492238 (score 10, accepted) https://quant.stackexchange.com/a/2929 All .NET languages are perfectly able to compete with the speed of C and even FORTRAN. It all depends on if they are used the correct way. 1) Both Java and .NET have considerable longer startup times than most native app. Therefore, you will have to have the application running and not starting it over and over on request. 2) Memory management is crucial when using managed heaps and if you are in need of reliable peak performance. Make sure, not to allocate large arrays over and over, since this will stress the GC too much and produce larger latencies. 3) Consider using optimized libraries. Some are around for C#/Visual Basic (ILNumerics) and Java (f.e. jblas). Recent tests have shown very good performance for numeric managed algorithms compared to native implementations and other frameworks. 4) Test your implementation and profile it! If you are positive, you could reach the performance goal with a C implementation, you can reach it with .NET as well. ## Answer by Joel Spolsky (score 11) https://quant.stackexchange.com/a/2928 The only way to find out is to try it! It shouldn't take very long to write some simple code to simulate the computations you plan to do, and run it in a loop. With current versions of Visual Basic (VB.net), performance should be comparable to Java in most cases because the basic technology (compiling to intermediate code and then running a just-in-time compiler) are roughly the same. Performance in C or C++ may be faster. Then again, it may not. The only way to find out is to try! ## Answer by user1194505 (score 2) https://quant.stackexchange.com/a/2953 Short answer: Yes. I am using it frequently. The stigma regarding Visual Basic comes from the time, where VB5 was COM based with some dirty language quirks. This time, VB was intended for/ to be used within / in conjunction with Office' macros. .NET substantially changed the technology behind the language as well as removed most 'quirks' regarding usability. It is now on par with C# and all other .NET languages regarding execution speed. ## Answer by Alexey Kalmykov (score 1) https://quant.stackexchange.com/a/2932 From the computational (math) prespective, VB.net should be able to compete with Java and C/C++. The only possible problem can be the garbage collection (as in Java). Therefore don't forget to set server-type garbage collector and carefully organize/manage your data structures. ## Answer by JohnAndrews (score -2) https://quant.stackexchange.com/a/3244 VBA is not useful for complex algorithms, in the sense that 1) coding is not efficient and 2) it has its limitations in terms of available resources on the net. You need to take into account that there are already a large number of institutions active in the high frequency segment, which means that they are your competitors. In order to ensure proper models (and to be faster than they are) you need to have excellent and efficient codes (COMPLEX!) optimized with the input of computer specialists. VBA is therefore a too simple language.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.