The current Perl client implementation relies on LWP::UserAgent in a strictly synchronous, blocking manner without explicit connection pooling. To align with hlquery's high-performance goals, the API should support persistent connections (HTTP Keep-Alive) and offer an asynchronous interface for modern Perl event loops.
Context
hlquery is a high-performance search engine where low latency is critical. The current Perl client (Hlquery::Request) establishes new TCP/TLS connections frequently, introducing significant overhead. Furthermore, in modern Perl environments like Mojolicious or AnyEvent, the blocking nature of the current client prevents concurrent operations, making it a bottleneck for high-throughput applications.
Proposed Implementation
- Connection Pooling: Integrate
LWP::ConnCache into Hlquery::Request to enable reuse of TCP connections across requests, reducing handshake latency.
- Asynchronous Client: Introduce a non-blocking client variant (e.g.,
Hlquery::AsyncClient) utilizing Mojo::UserAgent or Promises to allow concurrent search operations.
- Lazy JSON Decoding: Implement support for streaming or lazy decoding of large search results to minimize memory pressure when handling massive datasets.
Impact
- 30-50% Latency Reduction: Connection reuse avoids repeated TCP/TLS handshakes, which is critical for a high-performance search engine.
- Improved Concurrency: Enables Perl-based services to handle hundreds of concurrent search queries without blocking the main event loop.
- Better Resource Management: Reduced socket churn and memory footprint for large-scale indexing or search operations.
The current Perl client implementation relies on
LWP::UserAgentin a strictly synchronous, blocking manner without explicit connection pooling. To align withhlquery's high-performance goals, the API should support persistent connections (HTTP Keep-Alive) and offer an asynchronous interface for modern Perl event loops.Context
hlqueryis a high-performance search engine where low latency is critical. The current Perl client (Hlquery::Request) establishes new TCP/TLS connections frequently, introducing significant overhead. Furthermore, in modern Perl environments like Mojolicious or AnyEvent, the blocking nature of the current client prevents concurrent operations, making it a bottleneck for high-throughput applications.Proposed Implementation
LWP::ConnCacheintoHlquery::Requestto enable reuse of TCP connections across requests, reducing handshake latency.Hlquery::AsyncClient) utilizingMojo::UserAgentorPromisesto allow concurrent search operations.Impact