Perf experiment spike: Change 1on1 send/filter to partial pub-key

- Add MANY_WHISPER_TOPICS_ENABLED flag
- Jenknisfile.parameters
This commit is contained in:
Oskar Thoren 2018-01-05 20:29:13 +09:00 committed by Eric Dvorsak
parent 4a08d2a818
commit 3cdb05e5b8
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
8 changed files with 36 additions and 8 deletions

2
.env
View File

@ -9,3 +9,5 @@ LOG_LEVEL=debug
LOG_LEVEL_STATUS_GO=info
JSC_ENABLED=1
QUEUE_MESSAGE_ENABLED=1
MANY_WHISPER_TOPICS_ENABLED=0

View File

@ -9,3 +9,4 @@ LOG_LEVEL=debug
LOG_LEVEL_STATUS_GO=info
JSC_ENABLED=1
QUEUE_MESSAGE_ENABLED=1
MANY_WHISPER_TOPICS_ENABLED=0

View File

@ -8,4 +8,5 @@ OFFLINE_INBOX_MANY_ENABLED=0
LOG_LEVEL=info
LOG_LEVEL_STATUS_GO=info
JSC_ENABLED=0
QUEUE_MESSAGE_ENABLED=0
QUEUE_MESSAGE_ENABLED=0
MANY_WHISPER_TOPICS_ENABLED=0

View File

@ -47,6 +47,7 @@ node ('macos1') {
sh 'echo LOG_LEVEL_STATUS_GO=' + LOG_LEVEL_STATUS_GO + '>>' + '.env'
sh 'echo JSC_ENABLED=' + JSC_ENABLED + '>>' + '.env'
sh 'echo OFFLINE_INBOX_ENABLED=' + OFFLINE_INBOX_ENABLED + '>>' + '.env'
sh 'echo MANY_WHISPER_TOPICS_ENABLED=' + MANY_WHISPER_TOPICS_ENABLED + '>>' + '.env'
sh 'echo "**********************************************************************"'
sh 'echo PARAMETERIZED BUILD - USING CUSTOM ENVIRONMENT'

View File

@ -2,7 +2,7 @@
(:require [cljs.spec.alpha :as s]
[status-im.protocol.web3.filtering :as f]
[status-im.protocol.web3.delivery :as d]
[taoensso.timbre :refer-macros [debug]]
[taoensso.timbre :refer-macros [debug] :as log]
[status-im.protocol.validation :refer-macros [valid?]]))
(def message-defaults
@ -17,10 +17,11 @@
(defn send!
[{:keys [web3 message]}]
{:pre [(valid? ::user-message message)]}
(let [message' (merge message-defaults
(assoc message
:type :message
:requires-ack? true))]
(let [topics (f/get-topics (:to message))
message' (assoc message
:topics topics
:type :message
:requires-ack? true)]
(debug :send-user-message message')
(d/add-pending-message! web3 message')))

View File

@ -98,13 +98,13 @@
web3
{:key identity
:allowP2P true
:topics [f/status-topic]}
:topics (f/get-topics identity)}
(l/message-listener listener-options))
(inbox/initialize! web3))
(f/add-filter!
web3
{:key identity
:topics [f/status-topic]}
:topics (f/get-topics identity)}
(l/message-listener listener-options)))
;; start listening to profiles

View File

@ -1,11 +1,32 @@
(ns status-im.protocol.web3.filtering
(:require [status-im.protocol.web3.utils :as u]
[status-im.utils.config :as config]
[cljs.spec.alpha :as s]
[taoensso.timbre :as log]))
;; XXX(oskarth): Perf issue to have one topic
;; See https://github.com/status-im/ideas/issues/55#issuecomment-355511183
(def status-topic "0xaabb11ee")
(defonce filters (atom {}))
;; NOTE(oskarth): This has concerns for upgradability and chatting cross
;; versions. How can we do this breaking change gradually?
;; NOTE(oskarth): Due to perf we don't want a single topic for all messages,
;; instead we want many. We need a way for user A and B to agree on which topics
;; to use. By using first 10 characters of the pub-key, we construct a topic
;; that requires no coordination for 1-1 chats.
(defn identity->topic [identity]
(apply str (take 10 identity)))
(defn get-topics [& [identity]]
(if config/many-whisper-topics-enabled?
(do (log/info "FLAG: many-whisper-topics-enabled ON")
[(identity->topic identity)])
(do (log/info "FLAG: many-whisper-topics-enabled OFF")
[status-topic])))
(s/def ::options (s/keys :opt-un [:message/to :message/topics]))
(defn remove-filter! [web3 options]

View File

@ -32,3 +32,4 @@
(def jsc-enabled? (enabled? (get-config :JSC_ENABLED 0)))
(def queue-message-enabled? (enabled? (get-config :QUEUE_MESSAGE_ENABLED 0)))
(def many-whisper-topics-enabled? (enabled? (get-config :MANY_WHISPER_TOPICS_ENABLED 0)))