Skip to content

Performance Improvements #32

Closed
Closed
@jbuckmccready

Description

@jbuckmccready

Related to investigating the radix sort mentioned in #30 I found a few other ways to improve performance in my c++ usage.

In the quicksort function when the sub array is small enough (I found 8 to be a good size) switch to insertion sort, this resulted in about a 3% improvement when indexing.

// still stop sorting if within same node
if (left / NodeSize >= right / NodeSize) {
  return;
}

if (right - left < 8) {
  // faster than continuing with the quick sort
  insertionSort(values, boxes, indices, left, right);
  return;
}

When searching/querying the index I allow an existing container to be passed in to be used for both the results and the stack for traversal. This was a huge performance boost (20-30%) since I often perform the search in tight loops which would involve many allocation/deallocations for both the results and stack for traversal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions