Skip to content

Conversation

John-194
Copy link
Contributor

Can I add an option to set sequential mode?
Sequential can be more efficient because it does not have the scheduler's overhead, but it depends on the dataset. Here are the results from my testing:

PARLAY_NUM_THREADS: Not set
  ordered point cloud:
     New threaded:   1.23 ms; CPU: ~650%;
     New sequential: 1.23 ms; CPU:  100%; efficiency: 6.5x
     Original:       1.23 ms; CPU: ~650%; 
  shuffled point cloud:
     New threaded:   1.46 ms; CPU: ~650%
     New sequential: 2.31 ms; CPU:  100%; efficiency: 4.1x
     Original:       1.45 ms; CPU: ~650%
     
PARLAY_NUM_THREADS: 1
  ordered point cloud:
     New threaded:   2.64 ms; CPU:  100%
     New sequential: 1.23 ms; CPU:  100%; efficiency: 2.1x
     Original:       2.64 ms; CPU:  100%
  shuffled point cloud:
     New threaded:   3.70 ms; CPU:  100%
     New sequential: 2.33 ms; CPU:  100%; efficiency: 1.6x
     Original:       3.69 ms; CPU:  100%

Using sequential mode is faster than setting PARLAY_NUM_THREADS to 1.
To make this work, I used a simple if check in the main loop, but the performance cost is within a margin of error - unnoticeable.

Usage:

import dbscan

# set sequential, disable threading
dbscan.set_sequential()
print("sequential:", dbscan.get_sequential())
dbscan.DBSCAN(points, eps=1.5, min_samples=15)

# enable threading again
dbscan.set_sequential(False) 
print("sequential:", dbscan.get_sequential())
dbscan.DBSCAN(points, eps=1.5, min_samples=15)

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.

1 participant