MemMapPing

command module
v0.0.0-...-5ef7ee6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

README

Memory Mapped Ping Pong

A ping application implemented using memory mapped files, compare-and-swap and memory barriers.

Made to exemplify memory mapped performance for communication between processes.

./mmping PING
Two Processes: One Pings the other Pongs; using memory mapped files.
2023/07/04 00:05:11 PING 10M, 90.88/ns per ping, or 11.0M pings/sec
2023/07/04 00:05:12 PING 20M, 90.02/ns per ping, or 11.1M pings/sec
2023/07/04 00:05:13 PING 30M, 91.53/ns per ping, or 10.9M pings/sec
2023/07/04 00:05:14 PING 40M, 88.55/ns per ping, or 11.3M pings/sec
2023/07/04 00:05:14 PING 50M, 90.72/ns per ping, or 11.0M pings/sec

(on Intel(R) Core(TM) i7-8559U CPU @ 2.70GH, AMD/Ryzen 3800X is about 5.1M, Intel is better with compare-and-swap and memory barriers)

A normal ping would take:

ping -s 16 localhost 
PING localhost (127.0.0.1) 16(44) bytes of data.
24 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.041 ms
24 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.023 ms
24 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.034 ms
24 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.033 ms

0.041ms is about 41us or 41000ns. 0.024M (24K) pings/sec.

0.024M vs 11.0M is about 450 times faster.

To be fair, if the PING was being answer by another process, and not the kernel TCP stack, the time it takes to ping-pong would probably be twice as slow.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL