Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

testNameservers unit test is quite slow #1614

Closed
bboreham opened this issue Oct 30, 2015 · 3 comments
Closed

testNameservers unit test is quite slow #1614

bboreham opened this issue Oct 30, 2015 · 3 comments

Comments

@bboreham
Copy link
Contributor

It was timing out in CI, so I investigated where all the time went.

Around 60-80% of the time is in case-insensitive string comparisons; evidently Go's handling of Unicode makes this expensive.

The total number of entries managed by nameservers in the test goes up linearly with the number of iterations. For each iteration there is then a linear function of comparisons in IsSorted() and merge() and an n log n function in Sort(), although the test only ever sorts nontrivial arrays in the periodic gossip. For low-thousands numbers of iterations the IsSorted() and merge() ones are more expensive.

Thoughts on ways to speed it up:

  • We could cache the ToLower output, trade memory for CPU.
  • merge() could use binary search to find the insertion points; generally the incoming data is far smaller than the existing data.
  • Since DNS has special considerations for Unicode characters, it may be that the full generality of case-insensitive handling is unnecessary.

The next-highest impact seems to be garbage collection, but I didn't investigate that.

@bboreham
Copy link
Contributor Author

Actually I think the timeouts are caused by miekg/dns#282 which is causing a lot of allocation of error objects and hence garbage-collection.

@rade
Copy link
Member

rade commented Oct 31, 2015

That miek/dns issue is resolved now. But CircleCI is still failing on #1615.

@rade rade added this to the 1.2.1 milestone Oct 31, 2015
@bboreham
Copy link
Contributor Author

bboreham commented Nov 2, 2015

Addressed by holding on to the ToLower output in 609d458

@bboreham bboreham closed this as completed Nov 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants