Skip to content

Instantly share code, notes, and snippets.

@rhyolight
Last active February 3, 2017 19:59
Show Gist options
  • Save rhyolight/d8d6af7c171ccb36603fe79d29938b34 to your computer and use it in GitHub Desktop.
Save rhyolight/d8d6af7c171ccb36603fe79d29938b34 to your computer and use it in GitHub Desktop.
def saveSpatialPooler(sp, key):
proto = SpatialPoolerProto_capnp.SpatialPoolerProto.new_message()
sp.write(proto)
bytes = proto.to_bytes_packed()
redis.set(key, bytes)
def loadSpatialPooler(key):
bytes = redis.get(key)
proto = SpatialPoolerProto_capnp.SpatialPoolerProto.from_bytes_packed(bytes)
return SpatialPooler.read(proto)
@rhyolight
Copy link
Author

rhyolight commented Feb 3, 2017

Regarding line 11 above, Redis reads are fast, unpacking the bytes into a prototype is fast, but reading the prototype into an object is very slow.

SP ae530169 retrieval of 8667492 bytes from htm_sp_ae530169_-1 took 15.0139160156 ms
SP ae530169 proto creation took 10.8959960938 ms
SP ae530169 de-serialization of 8667492 bytes took 19511.9318848 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment