Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve filter subscriptions #2193

Open
wants to merge 4 commits into
base: weboko/peer-manager
Choose a base branch
from

Conversation

weboko
Copy link
Collaborator

@weboko weboko commented Oct 27, 2024

Problem

During debugging sessions our team had we determined points for improvement for Filter/Subscription entities.
It was clear that they can be improved with better handling of configuration and peer management.

Solution

This PR improves configuration handling and PeerManager as well as adds timed MessageCache.

Notes

This PR is second to #2191

Copy link

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 84.71 KB (+0.22% 🔺) 1.7 s (+0.22% 🔺) 7.2 s (+44.77% 🔺) 8.9 s
Waku Simple Light Node 135.16 KB (+0.19% 🔺) 2.8 s (+0.19% 🔺) 9.1 s (-8.09% 🔽) 11.8 s
ECIES encryption 22.88 KB (0%) 458 ms (0%) 1.2 s (-44.99% 🔽) 1.6 s
Symmetric encryption 22.37 KB (0%) 448 ms (0%) 3.1 s (+91.68% 🔺) 3.5 s
DNS discovery 70.49 KB (0%) 1.5 s (0%) 4.7 s (-18.27% 🔽) 6.1 s
Peer Exchange discovery 71.47 KB (0%) 1.5 s (0%) 5.6 s (+8.65% 🔺) 7 s
Local Peer Cache Discovery 65.08 KB (0%) 1.4 s (0%) 4.2 s (-43.86% 🔽) 5.5 s
Privacy preserving protocols 76.14 KB (0%) 1.6 s (0%) 7.9 s (+50.73% 🔺) 9.5 s
Waku Filter 78.58 KB (+0.16% 🔺) 1.6 s (+0.16% 🔺) 7 s (+56.55% 🔺) 8.6 s
Waku LightPush 75.15 KB (0%) 1.6 s (0%) 6.9 s (+12.86% 🔺) 8.4 s
History retrieval protocols 75.25 KB (0%) 1.6 s (0%) 5.5 s (+12.65% 🔺) 7 s
Deterministic Message Hashing 7.39 KB (0%) 148 ms (0%) 266 ms (-60.7% 🔽) 414 ms

Comment on lines 12 to +13
export async function createLightNode(
options: CreateWakuNodeOptions = {}
options: ProtocolCreateOptions = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProtocolCreateOptions used for a createNode argument -- perhaps change naming/functionality here?

@@ -31,6 +26,9 @@ type MetadataService = {

const log = new Logger("sdk:create");

const DefaultUserAgent = "js-waku";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we're using mostly SNAKE_CASE for constants

Comment on lines +61 to +68
if (this.messageCache.has(pubsubTopic, wakuMessage as IProtoMessage)) {
log.info(
`Skipping duplicate message for pubsubTopic:${pubsubTopic} peerId:${peerIdStr}`
);
return;
}

this.messageCache.set(pubsubTopic, wakuMessage as IProtoMessage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can move this to a private function

type Timestamp = number;

export class MessageCache {
private intervalID: number | undefined = undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
private intervalID: number | undefined = undefined;
private intervalId: number | undefined = undefined;

Comment on lines +71 to +73
log.info(
`requestRenew: Renewed peer ${peerId.toString()} to ${newPeer.id.toString()}`
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we provide a potential reason of why this could've failed?
Possibly no peers available to renew with?

@weboko weboko marked this pull request as ready for review January 15, 2025 23:17
@weboko weboko requested a review from a team as a code owner January 15, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants