Skip to content

Instantly share code, notes, and snippets.

View franz1981's full-sized avatar
🏠
Working from home

Francesco Nigro franz1981

🏠
Working from home
View GitHub Profile

Improving Service Time in Queuing Theory: A Disproportionate Impact on Response Time

In queuing theory, enhancing the service time—the duration it takes to serve a customer or process a request—can have a remarkably significant and often disproportionate impact on the overall response time. While it may seem intuitive that faster service leads to shorter waits, the mathematical principles of queuing theory reveal a non-linear relationship, meaning a small improvement in service speed can yield a much larger reduction in total time spent in the system, especially as the system becomes busier.

The response time is the total time a customer or request spends in a system, from arrival to departure. It is the sum of the waiting time (time spent in the queue) and the service time itself. The effectiveness of improving service time is most clearly understood through its effect on system utilization.


The Role of System Utilization

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
void* writer_thread(void* arg) {
package redhat.app.services.benchmark;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import java.util.Objects;
/**
* It's a growable ring buffer that allows to move tail/head sequences, clear, append, set/replace at specific positions.
*/
final class ArrayRingBuffer<T> {
private static final Object[] EMPTY = new Object[0];
// it points to the next slot after the last element
private int tailSequence;

Weird ASM produced around type guards

With

# VM version: JDK 17.0.7, Java HotSpot(TM) 64-Bit Server VM, 17.0.7+8-LTS-224

red.hat.puzzles.polymorphism.InstanceOfScalabilityBenchmark.encodeFullType -pencoderType=a -ppollutionCases=20000 -t 16 -f 4 -prof perfasm

where

Benchmark (same) (size) Mode Cnt Score Error Units
LowerCaseComparison.optimizedContentEqualsIgnoreCase true 8 avgt 10 6.896 ± 0.163 ns/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:CPI true 8 avgt 0.240 clks/insn
LowerCaseComparison.optimizedContentEqualsIgnoreCase:IPC true 8 avgt 4.161 insns/clk
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-dcache-load-misses true 8 avgt 0.007 #/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-dcache-loads true 8 avgt 36.741 #/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-icache-load-misses true 8 avgt ≈ 10⁻³ #/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-icache-loads
============================= C2-compiled nmethod ==============================
----------------------------------- Assembly -----------------------------------
Compiled method (c2) 1259 774 4 red.hat.puzzles.checks.LowerCaseComparison::optimizedContentEqualsIgnoreCase (12 bytes)
total in heap [0x00007f06e5229690,0x00007f06e522a3a0] = 3344
relocation [0x00007f06e52297f0,0x00007f06e5229818] = 40
main code [0x00007f06e5229820,0x00007f06e5229be0] = 960
stub code [0x00007f06e5229be0,0x00007f06e5229bf8] = 24
oops [0x00007f06e5229bf8,0x00007f06e5229c00] = 8
metadata [0x00007f06e5229c00,0x00007f06e5229c30] = 48
============================= C2-compiled nmethod ==============================
----------------------------------- Assembly -----------------------------------
Compiled method (c2) 204 763 4 red.hat.puzzles.checks.LowerCaseComparison::unoptimizedContentEqualsIgnoreCase (12 bytes)
total in heap [0x00007f0279223e90,0x00007f0279224bd8] = 3400
relocation [0x00007f0279223ff0,0x00007f0279224018] = 40
main code [0x00007f0279224020,0x00007f0279224420] = 1024
stub code [0x00007f0279224420,0x00007f0279224438] = 24
oops [0x00007f0279224438,0x00007f0279224440] = 8
metadata [0x00007f0279224440,0x00007f0279224478] = 56
package red.hat.puzzles.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
package red.hat.puzzles.http;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;