ludic.net: a message's record, bytes and lists kept - queued ones back to a pool once sent or taken, the inbox's two drains on, a read text interned
np_queue made a NetMsg and a buffer per message, every flush a new keep list, and every message that came in a NetMessage and a buffer; nr_text a new string per text read. A party plays at dozens a second, so all of it is kept now: a pool of MTU-sized records for the queue (a peer's two lists swapped by the flush), the inbox's records in two halves swapped when a message finds the inbox empty, net_written's one record, a relay hello's and a STUN request's bytes in one scratch buffer, and the texts read out interned. Tests: 6000 messages with the heap flat (Os.heap_bytes), and an inbox record that holds still across a drain and comes back two drains on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e6729b3123
commit
ca69a3f9ae
11 changed files with 134 additions and 20 deletions
|
|
@ -33,6 +33,7 @@ property NetPeer {
|
|||
acked: int = 0, # the highest id it has taken from us
|
||||
ack_due: bool = false,
|
||||
queue: []NetMsg,
|
||||
back: []NetMsg, # the queue's other list, filled by a flush and swapped in
|
||||
closing: bool = false, # let go once it has taken close_id
|
||||
close_id: int = 0,
|
||||
close_t: float = 0.0 # ... or at this net time, whichever comes first
|
||||
|
|
@ -51,6 +52,15 @@ export state NetState {
|
|||
net__cfg: NetConfig = new NetConfig
|
||||
net__facts: Queue<NetFact> = net__facts__new()
|
||||
net__seen: []string = new []string # guests already punched for
|
||||
net__free: []NetMsg = new []NetMsg # sent and taken (or stale): made again, never new (pool.ludic)
|
||||
net__ina: []NetMessage = new []NetMessage # the inbox's records, two halves
|
||||
net__inb: []NetMessage = new []NetMessage
|
||||
net__inn: int = 0
|
||||
net__in_on_b: bool = false
|
||||
net__sb: []byte = buffer(32) # a relay hello's or a STUN request's bytes
|
||||
net__wr: NetMessage = null # net_written's, kept
|
||||
net__tsb: StrBuf = sb_new(NET_MTU) # a text read out of a message, interned (a name comes every frame)
|
||||
net__ttb: StrTable = strs_new(4096)
|
||||
net__punch_ip: words = null
|
||||
net__punch_port: words = null
|
||||
net__punch_left: words = null
|
||||
|
|
@ -88,7 +98,6 @@ export state NetState {
|
|||
net__rl: int = 0
|
||||
net__rp: int = 0
|
||||
net__rbad: bool = false
|
||||
net__tb: []byte = buffer(NET_MTU) # text read out of a message, through one scratch buffer
|
||||
net__hello_b: []byte = buffer(NET_MTU) # the game's hello, sent again on every dial
|
||||
net__hello_l: int = 0
|
||||
net__hello_t: float = 0.0 # seconds since it went; -1 not yet
|
||||
|
|
@ -119,6 +128,7 @@ function net__peers_new() -> []NetPeer {
|
|||
for i in 0 .. NET_PEERS {
|
||||
let p = new NetPeer
|
||||
p.queue = new []NetMsg
|
||||
p.back = new []NetMsg
|
||||
push(out, p)
|
||||
}
|
||||
return out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue