joas_coder
public static void main(String[] args) {
Chatter chatter = new Chatter();
String text = "Hello " + chatter.getWord() + "!";
System.out.println(text);
free text; // destroy object and reclaim the memory
free chatter; // destroy object and reclaim the memory
// System.out.println(chatter); // use after free NEVER compiles
}
}// OR:
public class Hello {
public static void main(String[] args) {
Chatter chatter = new Chatter();
defer free chatter;
String text = "Hello " + chatter.getWord() + "!";
defer free text;
System.out.println(text);
}
}Unlike GraalVM Native Image, which takes existing Java bytecode and packages the required Java runtime components into a native executable, Ironwood is a separate language designed from the start around native execution and explicit compiler-enforced safe memory management.
It uses LLVM, like Rust and Zig, so the native code produced can be very fast. It has a "defer" keyword for deferred cleanup, like Zig.
What do you think of the idea?
> If it's not your first rodeo in compilers, IMHO just design your runtime primarly for register-passable values from day one, it might feel like premature optimization, but since the value model will permeate so much of the runtime, the knock-on effects once you do decide to fix it probably makes it worth to go with it from day 1.
Day one, definitely. Those were cheap to fix only because the value model never had to change.
Funny, Ironwood (https://github.com/ironwood-lang/ironwood) explores exactly this space: familiar Java programming without JVM startup, warmup, or GC.
The idea is to ship more powerful lightweight free models as they become available. I'm looking forward to Gemma 5!
> The biggest concern for an app like this is how much RAM you end up using trying to run it
You are totally right. A new feature for a future version would be to turn off the model when the app is idle. And only launch it next time the user takes a screenshot. It is a trade-off between latency to generate the names and memory RAM.
Show HN: I made a Gemma 4 Mac app that names screenshots with local AI
I made my first macOS utility app that ships with a bundled Gemma 4 model, specifically the Gemma E4B one. It made my app DMG have 5.3 GB in size, but I think it is a small size for the power that this free local model can provide.It runs fine on CPU, but can also run on Apple Silicon GPU, although I did not notice any performance improvements with GPU (tested on a M5 chip).I think these local...
C++ map slower than Java map: Code/Benchmark Issue?
In our tests, we observed better results with the HotSpot JVM 23 using JIT compilation. We got slower results with C++ (compiled with Clang 18), GraalVM 23 (compiled with native-image), and HotSpot JVM 23 with the -Xcomp flag. We are seeking to understand why this happens, and if possible, identify ways to improve the performance of the C++ version to match the results of Java's JIT compilation.
Our benchmark involves comparing a hash table (map) implementation in Java to an equivalent implementation in C++. We made every effort to ensure consistency between the two implementations, but it’s possible that some nuances were overlooked.
The hash table implementation itself is simple, and we aimed to make the Java and C++ code as equivalent as possible, including how memory is managed. For instance, we ensured that the C++ hash table values are stored by reference, not by value, to avoid unnecessary copying.
The benchmark creates a hash table with 5,000,000 buckets and inserts 10,000,000 objects, minimizing collisions. The linear search in each bucket is kept to a maximum of two iterations to avoid discrepancies in measurements due to varying collision behavior across different elements.
The Bench class, which handles the measurements, should also be equivalent in both implementations.
Given these details, does anyone have insights into why the C++ version of the benchmark was slower than the Java version? Could there be something we overlooked or an aspect of the C++ implementation that could be optimized further? Perhaps specific Clang optimization options we should explore?
The link to the project is here => https://github.com/coralblocks/CoralBench?tab=readme-ov-file...
Or on GitHub: https://github.com/coralblocks/CoralBench?tab=readme-ov-file...
There is also an ongoing discussion on SO => https://stackoverflow.com/questions/79268109/c-implementatio...
The GitHub for the project is at https://www.github.com/coralblocks/CoralBench
Good research of Java (JIT) vs. C++ (AOT) performance with interesting results
In our tests, we observed better results with the HotSpot JVM 23 using JIT compilation. We got slower results with C++ (compiled with Clang 18), GraalVM 23 (compiled with native-image), and HotSpot JVM 23 with the -Xcomp flag. We are seeking to understand why this happens, and if possible, identify ways to improve the performance of the C++ version to match the results of Java's JIT compilation.
Our benchmark involves comparing a hash table (map) implementation in Java to an equivalent implementation in C++. We made every effort to ensure consistency between the two implementations, but it’s possible that some nuances were overlooked.
The hash table implementation itself is simple, and we aimed to make the Java and C++ code as equivalent as possible, including how memory is managed. For instance, we ensured that the C++ hash table values are stored by reference, not by value, to avoid unnecessary copying.
The benchmark creates a hash table with 5,000,000 buckets and inserts 10,000,000 objects, minimizing collisions. The linear search in each bucket is kept to a maximum of two iterations to avoid discrepancies in measurements due to varying collision behavior across different elements.
The Bench class, which handles the measurements, should also be equivalent in both implementations.
Given these details, does anyone have insights into why the C++ version of the benchmark was slower than the Java version? Could there be something we overlooked or an aspect of the C++ implementation that could be optimized further? Perhaps specific Clang optimization options we should explore?
The link to the project is here => https://github.com/coralblocks/CoralBench?tab=readme-ov-file...
Although the numbers above are close, it does not make much sense to me that a chip with more CPUs will be faster on single thread performance than the same chip with less CPUs. But I can be wrong.
Also, according to their list, even the M3 8 Core beats the M4 chips (Pro and Max included). Again on single thread performance. Am I missing something?
Am I missing something or the M3 for single thread performance is faster than the M4?
I can't emphasize enough that I'm only talking about single thread performance here.
I HAVE NOW CHANGED THE TITLE => Thanks again!
According to PassMark CPU Benchmarks, a trusted source, updated frequently, the M3 Max 16 Core is the fastest single thread cpu with a score of 4,785, followed by the M3 Max 14 Core with a score of 4,771.
Although the numbers above are close, it does not make much sense to me that a chip with more CPUs will be faster on single thread performance than the same chip with less CPUs. But I can be wrong.
Also, according to this list, even the M3 8 Core beats the M4 chips (Pro and Max included). Again on single thread performance.
Am I missing something or the M3 for single thread performance is faster than the M4?
I can't emphasize enough that I'm only talking about single thread performance here.
CPUBenchmark.net says M3 is faster than all M4s on single thread performance
For the non-blocking ring, the producer never blocks on a full ring. It overwrites the circular ring. The consumer can still block on an empty ring.
So to make it clear:
Blocking ring => producer and consumer can block/wait
Non-Blocking ring => producer never blocks and consumer can still block on an empty ring. Consumer can also fall behind too much and disconnect.