• Stars
    star
    348
  • Rank 117,260 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 1 year ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A high performance inter-process communication golang library developed by CloudWeGo

Shmipc

English | 中文

Introduction

Shmipc is a high performance inter-process communication library developed by ByteDance. It is built on Linux's shared memory technology and uses unix or tcp connection to do process synchronization and finally implements zero copy communication across inter-processes. In IO-intensive or large-package scenarios, it has better performance.

Features

Zero copy

In an industrial production environment, the unix domain socket and tcp loopback are often used in inter-process communication.The read operation or the write operation need copy data between user space buffer and kernel space buffer.But shmipc directly store data to the share memory, so no copy compared to the former.

batch IO

An IO queue was mapped to share memory, which describe the metadata of communication data. so that a process could put many request to the IO queue, and other process could handle a batch IO per synchronization. It could effectively reduce the system calls which was brought by process synchronization.

Performance Testing

The source code bench_test.go, doing a performance comparison between shmipc and unix domain in ping-pong scenario with different package size. The result is as follows: having a performance improvement whatever small package or large package.

go test -bench=BenchmarkParallelPingPong -run BenchmarkParallelPingPong
goos: linux
goarch: amd64
pkg: github.com/cloudwego/shmipc-go
cpu: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
BenchmarkParallelPingPongByShmipc64B-40      	  733821	      1970 ns/op	  64.97 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc512B-40     	  536190	      1990 ns/op	 514.45 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc1KB-40      	  540517	      2045 ns/op	1001.62 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc4KB-40      	  509047	      2063 ns/op	3970.91 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc16KB-40     	  590398	      1996 ns/op	16419.46 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc32KB-40     	  607756	      1937 ns/op	33829.82 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc64KB-40     	  609824	      1995 ns/op	65689.31 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc256KB-40    	  622755	      1793 ns/op	292363.56 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc512KB-40    	  695401	      1993 ns/op	526171.77 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc1MB-40      	  538208	      1873 ns/op	1119401.64 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByShmipc4MB-40      	  606144	      1891 ns/op	4436936.93 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds64B-40         	  446019	      2657 ns/op	  48.18 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds512B-40        	  450124	      2665 ns/op	 384.30 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds1KB-40         	  446389	      2680 ns/op	 764.29 MB/s	       0 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds4KB-40         	  383552	      3093 ns/op	2648.83 MB/s	       1 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds16KB-40        	  307816	      3884 ns/op	8436.27 MB/s	       8 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds64KB-40        	  103027	     10259 ns/op	12776.17 MB/s	     102 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds256KB-40       	   25286	     46352 ns/op	11311.01 MB/s	    1661 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds512KB-40       	    9788	    122873 ns/op	8533.84 MB/s	    8576 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds1MB-40         	    4177	    283729 ns/op	7391.38 MB/s	   40178 B/op	       0 allocs/op
BenchmarkParallelPingPongByUds4MB-40         	     919	   1253338 ns/op	6693.01 MB/s	  730296 B/op	       1 allocs/op
PASS
ok  	github.com/cloudwego/shmipc	42.138s

  • BenchmarkParallelPingPongByUds, the ping-pong communication base on Unix domain socket.
  • BenchmarkParallelPingPongByShmipc, the ping-pong communication base on shmipc.
  • the suffix of the testing case name is the package size of communication, which from 64 Byte to 4 MB.

Quick start

HelloWorld

Integrate with application

HotRestart

hot restart demo

More Repositories

1

kitex

A high-performance and strong-extensibility Golang RPC framework that helps developers build microservices.
Go
3,720
star
2

netpoll

A high-performance non-blocking I/O networking framework, which focused on RPC scenarios, developed by ByteDance.
Go
2,325
star
3

volo

Rust RPC framework with high-performance and strong-extensibility for building micro-services.
Rust
2,018
star
4

hertz

A high-performance and strong-extensibility Go HTTP framework that helps developers build microservices.
Go
1,161
star
5

sonic-rs

A fast Rust JSON library based on SIMD.
Rust
273
star
6

dynamicgo

Dynamically and efficiently operate RPC data for Go
Go
114
star
7

biz-demo

Business Demo for CloudWeGo
Go
105
star
8

pilota

A thrift and protobuf implementation in pure rust with high performance and extensibility.
Rust
104
star
9

frugal

A very fast dynamic Thrift serializer & deserializer.
Go
100
star
10

thriftgo

An implementation of thrift compiler in go language.
Go
99
star
11

cwgo

An all-in-one code generation tool for CloudWeGo
Go
77
star
12

cloudwego.github.io

Website for CloudWeGo
JavaScript
59
star
13

kitex-examples

Go
50
star
14

netpoll-http2

Go
43
star
15

kitex-benchmark

Go
31
star
16

netpoll-benchmark

Go
18
star
17

hertz-examples

Examples for Hertz.
Go
18
star
18

localsession

Implicitly transmit context within or between goroutines
Go
14
star
19

configmanager

Go
7
star
20

kitex-tests

Tests for cloudwego/kitex
Go
2
star
21

netpoll-examples

Go
2
star
22

thrift-gen-validator

thrift-gen-validator is a thriftgo plugin to generate struct validators.
Go
2
star
23

community

Governance and community material for CloudWeGo and its open source sub-projects
1
star