[bisq-network/bisq] Reduce initial request size (#4233)

Florian Reimair notifications at github.com
Wed May 20 08:21:56 UTC 2020


@freimair commented on this pull request.



> +                                                    PersistableNetworkPayload payload) {
+        // make sure we do not add data that we already have (in a bin of historical data)
+        if (getMap().containsKey(hash))
+            return null;
+
+        PersistableNetworkPayload previous = store.getMap().putIfAbsent(hash, payload);
+        persist();
+        return previous;
+    }
+
+
+    @Override
+    public Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> getMap() {
+        HashMap<P2PDataStorage.ByteArray, PersistableNetworkPayload> result = new HashMap<>();
+        result.putAll(store.getMap());
+        history.forEach((s, store) -> result.putAll(store.getMap()));

I thought about that. The only thing that can be cached is loading the historical data stores into the result. And since these are read-only anyways, there is nothing that changes. So why not cache it?

Well, the maps of the stores are in memory as well. So the data is already there and ready to be transferred. The only redirection that happens when we do it like this is that we iterate through all stores and add the data to the result. Compare that to a "cached" map of historical data, the data has to be transferred as well. The only thing we gain by caching the data is we need more RAM while saving on a few instructions to iterate through history.

IMO The small computational overhead does outweigh adding the complexity of another caching layer that needs to be maintained.

Anyways, this piece of code is going to be deprecated by https://github.com/bisq-network/projects/issues/29 anyways. Then is the time IMO to really dial down performance.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4233#discussion_r427826888
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200520/aafa2a13/attachment.html>


More information about the bisq-github mailing list