4 ms·
It really sounds like a job for Java (Microsoft, I know, I know.)
by nurettin 1y ago
It really sounds like a job for Java (Microsoft, I know, I know.)
- adwn 1y ago> It really sounds like a job for Java Why?
- dontlaugh 1y agoBecause the JVM's JIT does already specialise based on runtime values.
- nurettin 1y agoHotspot (TM) JIT compiles java code to machine code when it detects hot code paths, speeding up execution during runtime, exactly the use case described in the article.
- adwn 1y agoDoesn't Hotspot have notoriously long warm-up times? Have those been exaggerated, or have they recently improved? If you know beforehand that you'll execute some piece of code many times, the most efficient approach is to JIT-compile it right away, and not only after a lot of time has passed.
- eddythompson80 1y agoThey have not been exaggerated and they have not improved (well, nothing outside standard, keeping up with inflation, type improvement) The JVM ecosystem has given up on jit warm up time for hotspot. There are other solutions like graal. Whenever I have to deal with Java projects I'm always astonished at how completely "normal" a 4 minute startup time for a REST endpoint project on a single core machine.
- nurettin 1y agoI don't know the latest metrics, I remember java servers being slow at first, then gradually picking up momentum. Are you saying that Java doesn't do what the article describes?
- adwn 1y ago> Are you saying that Java doesn't do what the article describes? That's right, Java doesn't do what the NativeJIT library does: Hotspot starts in an interpreted mode and only later JIT-compiles frequently executed code; NativeJIT, in contrast, immediately compiles the generated code, at least according to this description: Bing formulates a custom expression for each query and then uses NativeJIT to compile the expression into x64 code that will be run on a large set of candidate documents spread across a cluster of machines. I don't know the specifics, but my guess is that by the time Hotspot would even start compiling, the user has already received the results for their query. Ergo, Java – at least with the Hotspot VM – wouldn't be suitable for this task.
- nurettin 1y agoAh ok pedantism that's fine thanks.
- adwn 1y agoThat's not "pedantism". Java+Hotspot are literally unfit for the task at hand.
- nurettin 1y agoThey specifically mentioned compiling at runtime in the article. I cannot be convinced otherwise. Sorry.
- adwn 1y agoI started typing a reply to explain that "compiling at runtime" does not mean "having a warm-up phase before JIT-compilation", but this: > I cannot be convinced otherwise. made me think "why bother?". If you insist on being wrong, go on being wrong.
- whizzter 1y agoHaving written small compilers or other code-generators targeting both the JVM and .NET runtimes, i can say that the .NET equivalents have some extra simple options for scenarios like this. Both have always supported building libraries/assemblies and loading them (the ASM library+custom classloaders for Java and AssemblyBuilder in .NET are about equally capable). However .NET also has DynamicMethod that is specifically built to quickly build just small functions that aren't tied to larger contexts (similar API to asm/assemblybuilder). But an even easier option for stuff exactly like in the article that people don't widely really seem to know about is that Linq (yes that "sql-like" stuff) actually contains parts for deferred method building that can be easily leveraged to quickly produce customized native code methods. The neat part about the Linq-code generator is that you can just drop in plain C# code-blocks to be translataed by the C# compiler into Linq snippets and then with some helpers transform everything to Linq-tree's that can then be compiled. The benefit over Asm/AssemblyBuilder/DynamicMethod is that Linq nodes are basically an built-in AST that can be directly leveraged whereas the other API's requires some mapping of your own AST's to the respective stack-machines. https://asm.ow2.io/ https://asm.ow2.io/ https://learn.microsoft.com/en-us/dotnet/api/system.reflection.emit.assemblybuilder?view=net-9.0 https://learn.microsoft.com/en-us/dotnet/api/system.reflecti... https://learn.microsoft.com/en-us/dotnet/api/system.reflection.emit.dynamicmethod?view=net-9.0 https://learn.microsoft.com/en-us/dotnet/api/system.reflecti... https://learn.microsoft.com/en-us/dotnet/api/system.linq.expressions.expression-1.compile?view=net-9.0 https://learn.microsoft.com/en-us/dotnet/api/system.linq.exp...
- pjmlp 1y agoUsual remark regarding the age of bytecode systems and JIT (aka dynamic compilation), predating Java.