Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Fix crash #78 #79

Closed
wants to merge 1 commit into from
Closed

Fix crash #78 #79

wants to merge 1 commit into from

Conversation

kean
Copy link
Contributor

@kean kean commented Apr 11, 2020

Fixes #78.

The root cause is that Interface is not thread safe because of all of the lazy properties.

I measured the performance before and after on my project with 68 pages.

Before: 90 ms.
After: 100 ms.

This operation could probably be optimized by writing from 2-3 threads, but not from 68 DispatchQueue.concurrentPerform iterations. I'm not sure it is worth optimizing it in the first place.

@mattt
Copy link
Contributor

mattt commented Apr 16, 2020

Thanks for looking into this, @kean. I'm glad that we seem to have a handle on what was causing this race condition (my best guess was that it had something to do with SwiftSyntax, since it had been causing similar issues in its Swift 5.1 version).

A while back, when I was benchmarking swift-doc on a larger project (~500k loc / 10k files / 20k symbols), parallelizing this step dropped the runtime from ~10 minutes to <1 minute. For <100 pages, you're just about breaking even with the coordination cost of concurrentPerform.

Long term, it'd be great for us to add some performance tests to our integration process. In the short term, I'd like to see if we can resolve #78 by making Interface thread-safe. This may be as simple as converting the lazy properties to stored properties initialized with self-executing closures.

@kean kean closed this Apr 16, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

malloc crash “randomly”
2 participants