global message queue vs per process?

未关闭
#9 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
15/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
cpp

调研方向

该 issue 未指出任何文件、测试或入口点。首先确定现有的进程和消息队列实现,然后解决所列出的同步、生命周期、缓冲和消息标识问题。完成的要求是确定一个经过协商的队列设计,记录其权衡取舍,并明确实现范围。

由索引模型根据 Issue 内容生成。

描述

a global message queue would be a circular buffer of MessageBlocks, like this

class MessageBlock {
atomic <int> num_read=0;
vector <Message> messages;
};

aligned to cache lines? an ID number for the block?

when a process reads the block of messages, increment the num_read variable, when it reaches the number of running processes then that message can be overwritten

will need an atomic<int> for the end, add to this when writing a new block of messages

don't think I need a marker for the start since each process will remember where it last read

when a process is created or killed, send a ping message or a ProcessCreated/ProcessClosed message and when that message has num_read==open_processes then you know everything is caught up

pros: less cache pollution, less strain on memory bandwidth, less work for the engine not having to duplicate messages for each process or check which processes care about which messages, messages sent to the engine won't have to be reflected out to other processes

cons: more synchronization, a slow process could cause the buffer to fill up, circular buffer with variable length items is complicated

could also categorize messages for a few separate queues? use a bloom filter for the whole queue?

if I need a read/write lock, I can simply use an atomic<int>, just increment by 1 to add a reader, increment by 9999999 to add a writer

every message might need an ID to handle responses? or maybe only do it for specific messages that need it? will they need from_process_id? from_process_id could be for the whole block instead of per message

主要语言
C++
星标
0
派生
0
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Die4Ever/AsyncGameEngine 的其他 Issue

查看 Die4Ever/AsyncGameEngine 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。