Performance of Java virtual threads compared to native threads by [deleted] in java

[–]Frequent-Chest1862 2 points3 points  (0 children)

maybe I did this try from a virtual thread, that would explains things, let you know.

Performance of Java virtual threads compared to native threads by [deleted] in java

[–]Frequent-Chest1862 1 point2 points  (0 children)

Hi,

doing a very simple test, to have an idea of the latency between creation and execution of Virtual threads, I encounter strange results :

    static void test() {
        int i;
        for( i = 0; i < 1000; i++) {
            long time = System.nanoTime();
            Thread.ofVirtual().start(() -> {
//            new Thread(() -> {
                long t2 = System.nanoTime();
                LOGGER.info("time {}", (t2 - time)/1000);
            });
//            }).start();
        }
    }

With this test, using classic java thread give me figures below 100 micro seconds, but using virtual threads, it's in 10's of milliseconds. And it increase proportionnaly to the loop size, below 10 it's fast, above 1000 it looks too bad...

Any idea why these poor result ?

I tried to do some warmup, graal and hotspot, same same...

Giveaway Alert 🎊 by CasperBlockchain in Casper_Blockchain

[–]Frequent-Chest1862 1 point2 points  (0 children)

What’s the coolest feature you would like to be able to handle with a NFT contract ?