Skip to content

KAD-DHT Performance Regression for Test Environment #962

@yashksaini-coder

Description

@yashksaini-coder

Description

Following the security improvements in my recent PR #892 that replaced wildcard bind addresses with localhost-only binding, we need to enhance the DHT implementation to maintain both security and performance in test environments. The current implementation shows significant performance regression in the DHT test suite, particularly in tests/core/kad_dht/test_kad_dht.py::test_provide_and_find_providers.

Motivation

  • Test execution time has increased by ~66% (from sub-1s to ~1.66s approx.)
  • CI/CD pipeline efficiency is impacted after my PR is merged
  • The Development workflow has slowed down,
  • We have to balance security with testing performance

Current Implementation

The current implementation uses the hardcoded LISTEN_MADDR = "/ip4/127.0.0.1/tcp/0" in libp2p/tools/constants.py, forcing all libp2p components to bind exclusively to localhost. While this improves security, it creates significant delays in connection retries during DHT testing when nodes attempt peer discovery and communication.

It led to some impacts which we need to resolve to ensure proper development:-

  • Test performance degradation
  • No available workarounds
  • Affects the entire DHT test suite
  • Security improvements conflict with testing efficiency

Are you planning to do it yourself in a pull request ?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions