KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
To resolve this issue I have created an open source Java Thread Affinity library When I have a number of thread interacting closely it can reduce latency and increase throughput. For single threaded tasks it can still reduce jitter quite a bit. This program looks at the difference in time between calls to System.nanoTime() and reports those over 10x,000 ns. public class TimeJumpingMain { static final long IGNORE_TIME = 1000 * 1000 * 1000; // the first second to allow warmup. static final int minJump = 10; // smallest jump of 10 us. static final int midJump = 100; // mid size jump of 100 us. static final int bigJump = 1000; // big jump of 1 ms. public static void main(String... args) { int[] intervalTimings = new int[1000]; int[] jumpTimings = new int[1000]; long start = System.nanoTime(); long prev = start; long prevJump = start; int jumpCount = 0; int midJumpCount = 0; int bigJumpCount = 0; while (true) { long now = System.nanoTime(); long jump = (now - prev) / 1000; if (jump > minJump && now - start > IGNORE_TIME) { long interval = (now - prevJump) / 1000; if (jumpCount < intervalTimings.length) { intervalTimings[jumpCount] = (int) interval; jumpTimings[jumpCount] = (int) jump; } if (jump >= midJump) midJumpCount++; if (jump >= bigJump) bigJumpCount++; prevJump = now; jumpCount++; } prev = now; if (now - start > 120L * 1000 * 1000 * 1000 + IGNORE_TIME) break; } System.out.println("interval us\tdelay us"); for (
Tags (comma-separated)
Save Edits
Cancel