Calibre: More QoL tweaks (#7545)

* Wireless: Optimize memory usage in StreamMessageQueue (use an array of string ropes, that we only concatenate once). Allowed to relax the throttling, making transfers that much faster.
* Persist: Add a "zstd" codec, that uses the "luajit" codec, but compressed via zstd. Since both of those are very fast, it pretty much trounces everything in terms of speed and size ;).
* Persist: Implemented a "writes_to_file" framework, much like the existing "reads_from_file" one. And use it in the zstd codec to avoid useless temporary string interning.
* Metadata: Switch to the zstd codec.
This commit is contained in:
NiLuJe
2021-04-14 00:35:20 +02:00
committed by GitHub
parent 47c59e0e5a
commit ea3fa5c2c7
6 changed files with 111 additions and 24 deletions

View File

@@ -176,7 +176,7 @@ local CalibreSearch = InputContainer:new{
},
cache_books = Persist:new{
path = DataStorage:getDataDir() .. "/cache/calibre/books.dat",
codec = "luajit",
codec = "zstd",
},
}

View File

@@ -132,7 +132,8 @@ function CalibreWireless:JSONReceiveCallback(host, port)
-- NOTE: Closure trickery because we need a reference to *this* self *inside* the callback,
-- which will be called as a function from another object (namely, StreamMessageQueue).
local this = self
return function(data)
return function(t)
local data = table.concat(t)
this:onReceiveJSON(data)
if not this.connect_message then
this.password_check_callback = function()
@@ -546,7 +547,8 @@ function CalibreWireless:sendBook(arg)
end
end
-- switching to raw data receiving mode
self.calibre_socket.receiveCallback = function(data)
self.calibre_socket.receiveCallback = function(t)
local data = table.concat(t)
--logger.info("receive file data", #data)
--logger.info("Memory usage KB:", collectgarbage("count"))
local to_write_data = data:sub(1, to_write_bytes)