Skip to content

Performance on Windows #113

Closed
Closed
@pgreenland

Description

@pgreenland

Hey,

Firstly thanks for an awesome library!

I've been using it on Linux and now Windows as part of an ECU firmware updater. So been using the pure Python implementation.

It's been working well on both, however performance on Windows has been terrible compared to Linux.

As an example on Linux the main file transfer takes 10s, on Windows it takes 2mins.

I believe I've narrowed it down to the Timer implementation, which calls time.monotonic_ns. The resolution of that Timer on Windows doesn't appear to be very good.

Based on the discussion of time.monotonic here https://bugs.python.org/issue44328.

Tacking the following into my code resolves the issue:

if platform.system() == "Windows":
    # On windows patch time.monotonic_ns for isotp library.
    # It seems time.monotonic uses a timer which has a resolution of 16ms
    # See: https://bugs.python.org/issue44328
    # Instead we'll override it with our own version
    time.monotonic_ns = lambda: time.perf_counter() * 1000000000.0

Bringing the update time down to around 13-15s....not quite as good as Linux....but it's close enough. Watching the CAN traffic on another machine the inter-frame delay drops from 10-12ms to 1ms as requested by the remote device.

Thought it may be beneficial to others to fix the problem at source.

Thanks,

Phil

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions