Better HN
topnewbestaskshowjobs
Log inSign up

joas_coder

21 karma · joined Nov 28, 2024 (2y ago) · 59 submissions

Submissions

comment 1y ago · link · parent

I thought they were trustworthy but I can be wrong. Where is the screaming text in what site that you are referring to?

comment 1y ago · link · parent

Agree! But how about the M3 8 Core (4754) beating the M4 Max 14 Core (4614)? I thought the M4s were faster than the M3s (single core / single thread), but it looks like they will only be faster on multi core / multi thread benchmarks. I would think that the sheer speed of a CPU is the single core / single thread performance number.

comment 1y ago · link · parent

According to CPUBenchmark.net 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 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.

comment 1y ago · link · parent

I see. Sorry about that. Won't be putting any more comments in the title. Thanks for your guidance.

I HAVE NOW CHANGED THE TITLE => Thanks again!

comment 1y ago · link · parent

Sorry about that. I'm new here. Would you be so kind as to tell me what I did wrong? I'll be happy to correct it and learn not to do it again.

comment 1y ago · link · parent

Their official benchmarks => https://www.cpubenchmark.net/singleThread.html

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.

37.

CPUBenchmark.net says M3 is faster than all M4s on single thread performance(cpubenchmark.net ↗)

11 points · by joas_coder · 1y ago · 16 comments

comment 1y ago · link · parent

You were interested in the diamond queue, so just wanted to say that it is now released in our GitHub => https://github.com/coralblocks/CoralQueue?tab=readme-ov-file...

comment 1y ago · link · parent

You are going to block/wait yourself when availableToPoll() (now changed to availableToFetch() for clarity) returns 0. When that happens you can block/wait by busy spinning or by using a wait strategy. The blocking term means that the producer has to block/wait when the ring is full and the consumer has to block/wait when the ring is empty.

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.

40.

Developing Java applications without the Garbage Collector [video](youtube.com ↗)

3 points · by joas_coder · 2y ago · discuss

comment 2y ago · link · parent

Totally agree! Because of the zero-garbage and no-gc requirement we don't even use the JDK. We use Java as syntax language and write everything from scratch, even the data structures (java.util.HashMap produces garbage). So the bloated Java ecosystem does not affect us too much.

comment 2y ago · link · parent

This change is now released. Thanks knome and gpderetta for your suggestions and clarifications.

availableToPoll() is now availableToFetch()

poll() is now fetch()

peek() is now fetch(false)

Note that fetch() == fetch(true)

comment 2y ago · link · parent

That's fair! I would assume that was due to your comfort zone and muscle memory. Not because you found Java to be harder than C++. Usually a higher level language is easier to grasp, handle and manage than a lower level one.

comment 2y ago · link · parent

It is clear to me now that poll only removes if there is something to remove

A much better name would have been FETCH and not POLL

We'll be changing everything from poll to fetch in the next version => availableToFetch() and fetch()

comment 2y ago · link · parent

Oh, I see now. I thought he was talking about a computer language but he was actually talking about the English language. My bad.

So are you saying that POLL was a bad choice of name because polling means "check if there is something available and if there is get it"?

What would be a better name? How about availableToFetch and fetch? Any other better idea?

I don't like remove because you are not actually removing the object from the ring.

comment 2y ago · link · parent

Not a language difference, but a design difference. By calling availableToPoll before polling you can poll a batch of messages without blocking or locking on each message. This design decision allows the ring to perform batching naturally. And batching is very important for perfomance. java.util.concurrent.ConcurrentLinkedQueue does not support batching.

comment 2y ago · link · parent

CoralRing does not produce garbage, but it cannot control what other parts of your application choose to do. It will hand to your application a message without producing any garbage, now if you go ahead and produce garbage yourself then there is nothing CoralRing can do about that. Ultra-low-latency applications in Java are designed so that nothing in the critical path produces garbage.

comment 2y ago · link · parent

Totally agree! My understanding because of the use of the word "masochist" was that it was possible but difficult. Not that one language was better/worse than the other, in terms of performance.

comment 2y ago · link · parent

Well said and I couldn't agree more. There are top market makers and banks using Java for a fact. And other C++ firms as well. Some of them are considering or have considered the move to Java. Some have already done this move. Some will never do. I'm certain that it is trivial for a C++ programmer to code in Java. The opposite of course is not true. The whole point of Java as a language is to be higher-level than C++. I don't know if people have realized, but with GraalVM it is now possible to compile Java code entirely to native code ahead-of-time, like it is done with C++. Even before GraalVM there was already the -Xcomp option to force JIT compilation in the very first pass. However that does not necessarily mean that AOT is always preferable over JIT. It is not. Runtime profiling information so you can determine the critical path (hot spots) is amazing for some optimizations, such as aggressive inlining.

comment 2y ago · link · parent

LOL you have a point. But this is subjective. Someone could argue that a highly complex C++ system is masochism. The reality is: a lot of successful market makers, prop trading firms, banks, etc. use Java for ultra-low-latency financial systems. And of course some successful companies use C++ as well.

comment 2y ago · link · parent

CoralRing and CoralQueue (available on GitHub) are completely garbage-free. You can send billions of messages without ever creating garbage for the GC, so no GC overhead. This is paramount for real-time ultra-low-latency systems developed in Java. You can read more about it here => https://www.coralblocks.com/index.php/java-development-witho...

comment 2y ago · link · parent

> Given the documentation says that this is supposedly to be between JVMs, how do they handle the serialize/deserialize?

Your transfer object needs to implement MemorySerializable. Below two examples from CoralRing's GitHub:

https://github.com/coralblocks/CoralRing/blob/main/src/main/...

https://github.com/coralblocks/CoralRing/blob/main/src/main/...

The second one effectively allows you to send anything you want (as bytes) through the ring, making CoralRing message agnostic.

comment 2y ago · link · parent

I think you can take a look at the DiamondQueue, which is a Demultiplexer and a Multiplexer combined so that thread A dispatches a bunch of tasks to a fixed set of worker threads (W1, W2, W3, etc.) and then these worker threads use a Multiplexer to deliver the results to another thread B. Thread A and Thread B can also be the same thread. There is an example here => https://www.coralblocks.com/index.php/the-diamond-queue-demu...

The DiamondQueue should be soon available for free at the CoralQueue project on GitHub.

comment 2y ago · link · parent

> It looks like these are more lower level libraries so clients are supposed to block, but they are responsible for doing the blocking themselves.

You busy spin when blocking (fastest) or you can use a WaitStrategy from https://www.github.com/coralblocks/CoralQueue. You can see an example here: https://github.com/coralblocks/CoralQueue/blob/main/src/main...

> And given these are designed for "ultra-low-latency" systems, I don't think that's a big problem because the best blocking strategy is probably just to spin.

If you have an isolated and dedicated CPU core for your thread, that's correct. Busy-spinning is the fastest/best strategy.

> It would be nice if the docs were nicer though, considering this is a paid product...

CoralRing and CoralQueue are open-source and free at GitHub. There are also a lot of documentation and explanations on the GitHub README.me page (front page). The code has also a lot of comments.

comment 2y ago · link · parent

availableToPoll() is the method that blocks, because it can return 0 on an empty ring. When that happens you have to block, by for example busy spinning around availableToPoll() until it returns something to poll.

You are never supposed to call poll() without first calling availableToPoll(). How can you poll something if you don't know if there is something available to poll? This is very different than a ConcurrentLinkedQueue where you can call poll() on an empty queue and get a null to indicate that the queue is empty. Also because the ring is a circular queue, you have to know what you can safely poll before polling. That's all done through availableToPoll().

NOTE: By garbage here I don't think you are talking about GC garbage.

12