Skip to content

Strange performance issues on windows #42

@sh1nkey

Description

@sh1nkey

Did some benchmarks

Code example:

def timit(func):
    async def wrapper():
        begin = time.time()
        await func()
        stop = time.time()
        print(f"total time of {func.__name__}: {stop - begin}")

    return wrapper

@timit
async def natspy_main_nonconcurrent() :
    client = NATS()

    await client.connect('downtimer-nats1:4222')
    
    for _ in range(1_000_0):
        await client.publish("some", b"1")

    await client.close()


@timit
async def natsrpy_main_nonconcurrent() :
    client = Nats(
        addrs=['downtimer-nats1:4222']
    )

    await client.startup()

    for _ in range(1_000_0):
        await client.publish("some", b"1")

    await client.shutdown()

Output:

total time of natspy_main_nonconcurrent: 0.02205514907836914
total time of natsrpy_main_nonconcurrent: 2.494574546813965

Additional details:

  • ran on Windows 10
  • cProfile of natspy run shows 263970 function calls, cProfile of natsRpy shows 990367 function calls
  • when ran with bigger payload (2 million symbols), natsRpy becomes faster then natspy not by a big margin
  • running benchmark in Dockercontainer doesn't really change anything
  • with using gather, function call count becomes somewhat similar, though perfomance is also strange (natspy 0.05 vs natsRpy 0.45)

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