Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Support wildcard subscriptions + getter for known types (optimized) #40

Merged
merged 10 commits into from
May 20, 2020

Conversation

raulk
Copy link
Member

@raulk raulk commented May 20, 2020

This PR supersedes #34.
Implements libp2p/go-libp2p-core#153.

It implements wildcard subscriptions differently, by adding a dedicated wildcard node. It also validates emitters and subscriptions:

  • Rejects Emitters for wildcard subscriptions.
  • Rejects variadic subscriptions that include the wildcard. (Wildcard subscriptions must be started separately)

Benchmarks against master

Without atomic wildcard sink counter

benchmark                                               old ns/op     new ns/op     delta
BenchmarkEvents/subs-001/emits-001/stateful-false-8     124           146           +17.74%
BenchmarkEvents/subs-001/emits-016/stateful-false-8     191           206           +7.85%
BenchmarkEvents/subs-001/emits-256/stateful-false-8     203           230           +13.30%
BenchmarkEvents/subs-016/emits-001/stateful-false-8     3253          3299          +1.41%
BenchmarkEvents/subs-016/emits-016/stateful-false-8     3385          3028          -10.55%
BenchmarkEvents/subs-016/emits-256/stateful-false-8     3513          3611          +2.79%
BenchmarkEvents/subs-256/emits-001/stateful-false-8     50084         49766         -0.63%
BenchmarkEvents/subs-256/emits-016/stateful-false-8     47577         45560         -4.24%
BenchmarkEvents/subs-256/emits-256/stateful-false-8     44206         47754         +8.03%
BenchmarkEvents/subs-001/emits-001/stateful-true-8      120           148           +23.33%
BenchmarkEvents/subs-001/emits-016/stateful-true-8      200           207           +3.50%
BenchmarkEvents/subs-001/emits-256/stateful-true-8      214           229           +7.01%
BenchmarkEvents/subs-016/emits-001/stateful-true-8      3407          3218          -5.55%
BenchmarkEvents/subs-016/emits-016/stateful-true-8      3308          3503          +5.89%
BenchmarkEvents/subs-016/emits-256/stateful-true-8      3627          3775          +4.08%
BenchmarkEvents/subs-256/emits-001/stateful-true-8      50086         47147         -5.87%
BenchmarkEvents/subs-256/emits-016/stateful-true-8      46958         51912         +10.55%
BenchmarkEvents/subs-256/emits-256/stateful-true-8      45118         46186         +2.37%

With atomic wildcard sink counter (this PR)

⟩ benchcmp {before,after2}.txt
benchmark                                               old ns/op     new ns/op     delta
BenchmarkEvents/subs-001/emits-001/stateful-false-8     124           125           +0.81%
BenchmarkEvents/subs-001/emits-016/stateful-false-8     191           178           -6.81%
BenchmarkEvents/subs-001/emits-256/stateful-false-8     203           209           +2.96%
BenchmarkEvents/subs-016/emits-001/stateful-false-8     3253          3236          -0.52%
BenchmarkEvents/subs-016/emits-016/stateful-false-8     3385          3337          -1.42%
BenchmarkEvents/subs-016/emits-256/stateful-false-8     3513          3651          +3.93%
BenchmarkEvents/subs-256/emits-001/stateful-false-8     50084         46929         -6.30%
BenchmarkEvents/subs-256/emits-016/stateful-false-8     47577         52067         +9.44%
BenchmarkEvents/subs-256/emits-256/stateful-false-8     44206         44952         +1.69%
BenchmarkEvents/subs-001/emits-001/stateful-true-8      120           128           +6.67%
BenchmarkEvents/subs-001/emits-016/stateful-true-8      200           181           -9.50%
BenchmarkEvents/subs-001/emits-256/stateful-true-8      214           201           -6.07%
BenchmarkEvents/subs-016/emits-001/stateful-true-8      3407          3361          -1.35%
BenchmarkEvents/subs-016/emits-016/stateful-true-8      3308          3530          +6.71%
BenchmarkEvents/subs-016/emits-256/stateful-true-8      3627          3595          -0.88%
BenchmarkEvents/subs-256/emits-001/stateful-true-8      50086         48324         -3.52%
BenchmarkEvents/subs-256/emits-016/stateful-true-8      46958         51369         +9.39%
BenchmarkEvents/subs-256/emits-256/stateful-true-8      45118         52283         +15.88%

@aarshkshah1992
Copy link

This is beautiful.

@raulk
Copy link
Member Author

raulk commented May 20, 2020

Gonna merge because I need to make progress. Feel free to review after the fact.

@raulk raulk merged commit 6b6139f into master May 20, 2020
@raulk raulk deleted the feat/wildcard-subs branch May 20, 2020 17:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants