Buffered Send

From ShoutIRC RadioBot Wiki
Revision as of 09:53, 25 October 2013 by Indy (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Buffered Send aka SendQ system was a new feature in IRCBot v3. It assures that any asynchronous I/O does not cause problems on your IRC servers and also ensures the bot does not send so much data as to flood itself off the network.

The SendQ in IRCBot v3 had 2 levels: low priority spam/bulk data and high priority interactive data, this worked pretty well.

It was completely revamped and rewritten for IRCBot v4.

There are now up to 256 priority levels (although I can't imagine using that many). By default, RadioBot uses:

PRIORITY_LOWEST              0
Lowest priority bulk data (mostly LogChan stuff)
PRIORITY_SPAM                1
Slightly higher priority for channel spamming/song updates/etc.
PRIORITY_DEFAULT             10
The default priority for data that isn't specified as another level.
The Interactive priority is for responses from !triggers and other cases where a minimal amount of delay is wanted
The Immediate priority is for data where minimal delay is important. This level is limited to things like server logins/channel operations/ping replies/etc.

WARNING: Technical Data follows!!!


This diagram shows an overview of the SendQ priority system.
New v4 sendq.png

Data is sent in descending priority (ie. 99 will be sent first, 0 last), all of the data blocks from the highest level will be sent before moving on to lower levels.

Algorithm Implementation

This system could easily be implemented in C structures (linked lists, dynamically allocated arrays, etc.) or in C++ using STL map (for the priority levels) and vectors/queues for the FIFOs.

Algorithm Limitations

Just a note for anyone who wants to implement a similar system. This SendQ was designed for rate-limited IRC connections where there will be lots of times when higher levels will be empty for lower levels to get their data sent. If you use a system where higher priority classes are almost always full you could choke-out the lower levels and the data may never be sent, in order to remedy that you would need to modify the system to not send all data in the highest class before moving on to the next level. This could easily be done by basing the number of data chunks to send on the priority. (ie if there was a Priority of 5 it would send 5 data chunks before moving to the next lower level and looping around back to the highest level when it reaches the bottom)

RadioBot vde

RadioBot main pages
Main PageInstallationChangelogCommandsPluginsFAQConfigurationCreditsRemote ClientBuilt-In VariablesMulti Sound Server ModeUsername Character Restrictions
Auto DJ Pages
Auto DJ Main PageWebRequest SystemSchedulerMP3 EncoderVoice SupportMySQL Plugin
RadioBot Programming vde

RadioBot Programming
Plugin APIRemote CommandsPlugin InitializationRadioBot DBChanging Command PermissionsShoutIRC Music Database
Lua Scripting
Lua PluginLua ScriptingLua Events