Skip to content

Slcan speed optimization - #15

Merged
bendyer merged 2 commits into
masterfrom
slcan_speed_optimization
Dec 16, 2015
Merged

Slcan speed optimization#15
bendyer merged 2 commits into
masterfrom
slcan_speed_optimization

Conversation

@pavel-kirienko

Copy link
Copy Markdown
Member

This parser is much faster. It prevents data loss even on a fully congested bus at 1Mbps.

…ing parser could not keep up with data flow on a hevily loaded bus.
@bendyer

bendyer commented Dec 8, 2015

Copy link
Copy Markdown

Fun!

What is the rationale behind using threading.Thread rather than multiprocessing.Process? I would expect the GIL to negate much of the benefit of the speed-optimized parser when used in an application doing work on the main thread.

@pavel-kirienko

Copy link
Copy Markdown
Member Author

GIL indeed is an issue, but having a secondary thread simplifies the
parser, and also helps to avoid buffer overruns if the main thread
transiently blocks outside of conn.read().

Do you think using multiprocessing here is a sensible idea?

Fun!

What is the rationale behind using threading.Thread rather than
multiprocessing.Process? I would expect the GIL to negate much of the
benefit of the speed-optimized parser when used in an application doing
work on the main thread.


Reply to this email directly or view it on GitHub
#15 (comment).

@bendyer

bendyer commented Dec 8, 2015

Copy link
Copy Markdown

I always use separate processes if I'm breaking a task out to improve throughput. In this case the objective is reduced latency rather than increased throughput, but I suspect a separate process will be better for that too.

Using a separate process would probably require socket management be moved to that process, but it also avoids thread-safety problems since it forces looser coupling of tasks (e.g. via queues). I generally find that model easier to reason about than a shared-state+threading approach, although it can be more of a hassle to set up.

@pavel-kirienko

Copy link
Copy Markdown
Member Author

There are two more data points worth considering.

  • The current approach seems to fix the problem, so there's risk that switching to multiprocessing would be solving a nonexistent problem. That said, I fully agree with your coupling argument.
  • Multiprocessing does not guarantee that the child daemon thread exits when the parent terminates. This may add all sorts of peculiar issues, especially considering that we care about cross-platforming.

I'm not sure further throughput/latency improvements worth the hassle.

@pavel-kirienko

Copy link
Copy Markdown
Member Author

@bendyer I propose to accept this implementation since at any rate it offers better throughput than what we currently have in master. It is unclear to me whether it is necessary to tinker with multiprocessing at this point.

bendyer added a commit that referenced this pull request Dec 16, 2015
@bendyer
bendyer merged commit 3cd9274 into master Dec 16, 2015
@pavel-kirienko
pavel-kirienko deleted the slcan_speed_optimization branch December 16, 2015 08:46
pavel-kirienko added a commit that referenced this pull request Jul 18, 2026
…ference

Review finding #15 (Low). The reference selects the right neighbor with
cavl2_predecessor, an inclusive floor (offset <= right), so a fragment
beginning exactly at the new fragment's end participates in overlap
eviction; Python used a strict '<'. The divergence is observable only when
overlapping fragments carry conflicting data (corruption or adversarial
injection): the reference evicts the conflicting fragment and delivers the
transfer, while Python kept it and dropped the transfer on CRC failure.
Reference: udpard.c rx_fragment_tree_update.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CabiCDQ5DNBYq8WDKRzG4Z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants