Skip to content

optimize bit-to-byte boundary math to prevent empty slack byte allocation - #438

Merged
ec- merged 1 commit into
ec-:mainfrom
HoneyBunnyQT:optimize-slack-byte
Sep 15, 2026
Merged

ec- merged 1 commit into
ec-:mainfrom
HoneyBunnyQT:optimize-slack-byte

Conversation

@HoneyBunnyQT

@HoneyBunnyQT HoneyBunnyQT commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

when working on my q3decode tool i went real deep into the quake 3 network packets and found some real confusing sing which gave me lot of headache actually until i discovered

whenever the huffman coded packet ended at byte's end which can be the case in 1/8th of all packets the packet had an extra empty byte at the end

so i tracked it down to byte boundary math in qcommon/msg.c and qcommon/huffman.c and instead of doing (x>>3)+1 we better do (x+7)>>3 to make nice rounding and only hop to next byte when really needed

i tested against unmodified server on other side and no issues

over 25 years with 788 million seconds and 15,000 players online globally using all id tech 3 games 24/7 especially accounting for massive peaks in the 2000s with 20 packets per second from server and 60 packets from client that can be 788,000,000 x 15,000 x 80 = 946 trillion packets of which 1/8th carried a wasted byte that can be sum up to 107.5 terra bytes oh mein gott i sink john carmack clogged the internet

p. s. my coding can be better then my english off korrs :)

@ec-
ec- merged commit 2ec5165 into ec-:main Sep 15, 2026
28 checks passed
@HoneyBunnyQT
HoneyBunnyQT deleted the optimize-slack-byte branch September 16, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants