SMIPC
A light IPC DLL based on share memory.
github地址:
https://github.com/missionlove/SMIPC
SMIPC 是一个基于 Windows 共享内存(Shared Memory)的轻量级 IPC 库,面向低延迟、高吞吐的本机进程通信场景。
项目核心逻辑
SMIPC 的核心是"数据区 + 事件队列"的双层设计:
- 数据区(Buffer):使用共享内存存放 payload。
- 事件队列(IO Event Queue) :仅传递事件元数据(
event_code、event_id、user_tag、buffer_ref)。 - 同步原语:通过互斥量和信号量实现并发安全与阻塞唤醒。
- 业务状态位 :
working_flag由业务方维护,表达"是否仍有待处理工作"。
典型流程(进阶模式):
smipc_buffer_write写入 payload,得到buffer_refsmipc_event_push推送事件(携带buffer_ref)- 接收方
smipc_event_pop后smipc_buffer_read取数据
此外也提供简化模式:smipc_send / smipc_receive,用于快速接入。
项目目标
- 提供一个简单、稳定、可嵌入的 Windows IPC DLL。
- 支持请求-响应、批量消息、优雅关闭等常见业务模式。
- 在保证接口清晰的前提下,提供较好的延迟和吞吐表现。
项目优点
- 低开销:数据在本机共享内存中流转,避免额外序列化/网络栈开销。
- 接口分层清晰:既有简化 API,也有可控度更高的事件+缓冲区 API。
- 扩展性好:支持批量 push/pop、多线程、可选 TCP 同步通知。
- 工程可落地 :仓库内包含
ServerDemo、ClientUI、Tests、Benchmark示例与验证代码。
性能数据(本地压测)
压测程序:x64/Release/SMIPC.Benchmark.exe
测试命令(本次数据来源):
SMIPC.Benchmark.exe 50000 64 1 1SMIPC.Benchmark.exe 50000 256 1 1SMIPC.Benchmark.exe 50000 1024 1 1SMIPC.Benchmark.exe 30000 64 8 1SMIPC.Benchmark.exe 50000 64 1 4
说明:数据为单机实测结果,用于趋势参考;不同 CPU/负载/编译选项下数值会变化。
压测结果表
| 场景 | 参数(rounds,payload,batch,threads) | QPS (msg/s) | 吞吐 (MB/s) | 平均延迟 (us/msg) | P50 (us) | P90 (us) | P99 (us) |
|---|---|---|---|---|---|---|---|
| 单线程小包 | 50000, 64B, 1, 1 | 89,358.9 | 10.91 | 11.19 | 10.6 | 12.4 | 18.8 |
| 单线程中包 | 50000, 256B, 1, 1 | 86,150.6 | 42.07 | 11.61 | 10.8 | 12.9 | 19.4 |
| 单线程大包 | 50000, 1024B, 1, 1 | 85,817.4 | 167.61 | 11.65 | 11.0 | 12.9 | 19.1 |
| 批处理模式 | 30000, 64B, 8, 1 | 191,637 | 23.39 | 5.22 | 40.8* | 52.6* | 61.3* |
| 4线程并发 | 50000, 64B, 1, 4 | 252,629 | 30.84 | 3.96 | 14.2* | 20.2* | 31.1* |
* 说明:批处理/多线程下,p50/p90/p99 的统计口径与单线程单条消息不同(Benchmark 程序会输出口径说明)。
QPS 图示(基于以上数据)
SMIPC Benchmark QPS 64B-1T 256B-1T 1024B-1T 64B-B8 64B-4T 260000 240000 220000 200000 180000 160000 140000 120000 100000 80000 60000 40000 20000 0 msg/s
1) 压测命令模板
powershell
SMIPC.Benchmark.exe <rounds> <payload_bytes> [batch_size] [threads]
推荐至少覆盖以下场景:
- 单线程:
50000 64 1 1 - 单线程:
50000 256 1 1 - 单线程:
50000 1024 1 1 - 批处理:
30000 64 8 1 - 多线程:
50000 64 1 4
2) 测试环境信息模板
text
[Hardware]
CPU Model : <e.g. Intel Core i7-12700H / AMD Ryzen 7 7840H>
CPU Cores : <physical/logical, e.g. 6P+8E / 20 threads>
CPU Frequency : <base/turbo, and whether fixed frequency was used>
Memory : <size + speed, e.g. 32GB DDR5-5600>
Storage : <SSD model, optional>
[OS]
OS Version : <e.g. Windows 10 22H2 build xxxx>
Background Load: <idle / moderate / heavy>
[Build]
Solution/Target: <e.g. SMIPC.sln / x64 Release>
Compiler : <MSVC version>
Optimization : </O2, LTCG on/off, debug symbols on/off>
Runtime Library : </MD or /MT>
[Power]
Power Mode : <Best performance / Balanced / Power saver>
Power Plan : <Windows power plan name>
Thermal State : <normal / throttling observed>
[Benchmark Config]
Executable : <path to SMIPC.Benchmark.exe>
Rounds/Payload : <exact args>
Batch/Threads : <exact args>
Run Count : <e.g. 3 runs, take median>
文档
