Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: qwj/python-proxy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: by275/python-proxy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 7 commits
  • 7 files changed
  • 3 contributors

Commits on Nov 17, 2024

  1. Configuration menu
    Copy the full SHA
    19bc0b5 View commit details
    Browse the repository at this point in the history

Commits on Feb 9, 2026

  1. Configuration menu
    Copy the full SHA
    0791bce View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2026

  1. Python 3.12 compatibility and proxy hot-path optimizations (#3)

    * Add Python 3.12 asyncio compatibility updates
    
    - replace legacy asyncio task scheduling with create_task() in hot paths
    - switch loop access to get_running_loop() and explicit event loop setup for Python 3.12+
    - move AuthTable auth caches from class state to instance state to avoid cross-connection leakage
    - update package metadata to declare Python 3.12+ support
    
    * Add gitignore for Python cache files
    
    - ignore __pycache__/ directories generated by local Python runs
    
    * Add local proxy benchmark script
    
    - compare direct, HTTP, and SOCKS relay throughput on a local echo server
    - report request rate, bandwidth, average latency, and p95 latency
    - allow running from the repository root without installing the package
    
    * Optimize HTTP and WebSocket header parsing
    
    - share HTTP/WS request-head parsing to reduce repeated decode(), split(), and temporary header dict creation
    - reuse filtered header bytes when rebuilding HTTP request lines in accept and channel paths
    - benchmark basis: compared current proto.py against commit 53a2919 with tests/benchmark_http_headers.py, 5 runs each, 20000 iterations, 20 extra headers
    - measured improvement: http_accept 17.58us -> 16.84us (~4.2% faster), http_channel 17.63us -> 16.85us (~4.4% faster), ws_accept 16.82us -> 15.68us (~6.8% faster)
    
    * Reduce drain frequency in relay loops
    
    - batch relay writes up to 256 KiB before awaiting drain() in generic and HTTP relay paths
    - keep forced drain() for response paths that must flush immediately
    - benchmark basis: compared current proto.py against commit f888a39 with tests/benchmark_proxy.py, 5 runs each, 400 requests, concurrency 20, payload 16384 bytes, warmup 3
    - measured improvement: HTTP relay 9666 req/s -> 9818 req/s (~1.6% faster), SOCKS5 relay 8788 req/s -> 8907 req/s (~1.3% faster), with lower average latency on both paths
    
    * Optimize UDP relay bookkeeping
    
    - replace O(n) udpmap eviction scans with OrderedDict-based LRU tracking in ProxyDirect
    - reuse udpmap lookups and centralize touch/discard helpers for UDP connection state updates
    - preserve existing round-robin scheduling after rejecting the attempted rr cursor change
    - benchmark basis: synthetic UDP bookkeeping microbenchmark comparing previous min(update) eviction against the new LRU path across sizes 30, 100, 300, and 1000
    - measured improvement: about +475% at size 30, +480% at size 100, +451% at size 300, and +724% at size 1000
    
    * Reduce stat updater allocation overhead
    
    - replace nested lambda-based stat updaters with ConnectionStat and StatUpdater helper objects
    - keep the existing modstat call shape while avoiding repeated closure creation on connection setup
    - benchmark basis: synthetic modstat microbenchmark comparing the previous nested-lambda updater against the new object-based updater
    - measured improvement: 2189206 ops/s -> 3896353 ops/s (~78.0% faster)
    
    * Group relay tasks with asyncio.TaskGroup
    
    - add a relay_with_taskgroup helper and await paired inbound/outbound relay tasks inside stream_handler
    - keep the existing echo and empty fast paths unchanged while grouping the main bidirectional proxy relay lifecycle
    - benchmark basis: compared current server.py against commit 67523d9 with tests/benchmark_proxy.py, 5 runs each, 400 requests, concurrency 20, payload 8192 bytes, warmup 3
    - validation result: no large regression observed; direct throughput changed from 23336 req/s to 22811 req/s (~-2.3%), HTTP from 9953 req/s to 10436 req/s (~+4.9%), and SOCKS5 from 10022 req/s to 9654 req/s (~-3.7%), with smoke benchmark and compileall both passing
    
    * Reduce byte-processing overhead in protocol hot paths
    
    - decode HTTP admin header blocks once and reuse both the header dict and rendered line text
    - switch HTTP request-line detection in http_channel() to the bytes-based matcher to avoid per-chunk decode on the fast path
    - avoid extra bytes reallocation in SOCKS domain parsing by splitting the length byte from the host payload
    - centralize WebSocket frame masking with xor_mask_bytes() to simplify the byte-processing path used for masking and unmasking
    - validation: python3 -m compileall pproxy and python3 tests/benchmark_proxy.py --requests 50 --concurrency 5 --payload-size 4096 --warmup 1 both passed
    
    * Clean up asyncio task imports and Transparent interface
    
    - replace module-level create_task aliases with from asyncio import create_task in proto.py and server.py
    - add a default Transparent.query_remote() implementation so static analysis can see the required interface
    by275 authored Apr 18, 2026
    Configuration menu
    Copy the full SHA
    5fa9b14 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b22652a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d96a60e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9ffe502 View commit details
    Browse the repository at this point in the history

Commits on Apr 19, 2026

  1. Configuration menu
    Copy the full SHA
    768d87a View commit details
    Browse the repository at this point in the history
Loading