Seen, ChannelUserDictionary: Internalize channel names.

They are not many of them, but they are used a lot so they take
up a surprising amount of memory.
This commit is contained in:
Valentin Lorentz 2020-05-17 21:09:00 +02:00
parent 08f4c781cb
commit 2682e4cb48
2 changed files with 4 additions and 0 deletions

View File

@ -65,6 +65,7 @@ class SeenDB(plugins.ChannelUserDB):
def update(self, channel, nickOrId, saying): def update(self, channel, nickOrId, saying):
seen = time.time() seen = time.time()
channel = sys.intern(channel)
self[channel, nickOrId] = (seen, saying) self[channel, nickOrId] = (seen, saying)
self[channel, '<last>'] = (seen, saying) self[channel, '<last>'] = (seen, saying)

View File

@ -31,6 +31,7 @@
import gc import gc
import os import os
import csv import csv
import sys
import time import time
import codecs import codecs
import string import string
@ -188,6 +189,7 @@ class ChannelUserDictionary(collections.abc.MutableMapping):
def __setitem__(self, key, v): def __setitem__(self, key, v):
(channel, id) = key (channel, id) = key
channel = sys.intern(channel)
if channel not in self.channels: if channel not in self.channels:
self.channels[channel] = self.IdDict() self.channels[channel] = self.IdDict()
self.channels[channel][id] = v self.channels[channel][id] = v
@ -242,6 +244,7 @@ class ChannelUserDB(ChannelUserDictionary):
except ValueError: except ValueError:
# We'll skip over this so, say, nicks can be kept here. # We'll skip over this so, say, nicks can be kept here.
pass pass
channel = sys.intern(channel)
v = self.deserialize(channel, id, t) v = self.deserialize(channel, id, t)
self[channel, id] = v self[channel, id] = v
except Exception as e: except Exception as e: