This is an archive of the discontinued LLVM Phabricator instance.

Run the resolver in parallel with the reader.
ClosedPublic

Authored by ruiu on Jan 15 2015, 1:12 AM.

Details

Summary

This patch makes File::parse() multi-thread safe. If one thread is running
File::parse(), other threads will block if they try to call the same method.
File::parse() is idempotent, so you can safely call multiple times.

With this change, we don't have to wait for all worker threads to finish
in Driver::link(). Previously, Driver::link() calls TaskGroup::sync() to
wait for all threads running File::parse(). This was not ideal because
we couldn't start the resolver until we parse all files.

This patch increase parallelism by making Driver::link() to not wait for
worker threads. The resolver calls parse() to make sure that the file
being read has been parsed, and then uses the file. In this approach,
the resolver can run with the parser threads in parallel.

(This patch also opens up a possibility to read files from archive files
speculatively. Currently, reading member files from an archive file is
pretty slow because it's serialized, since the resolver is a single-
threaded routine. We could speed this thing up by instantiating member
files that are likely to be needed. As long as a file instantiation and
its parse() method are side-effect free, that operation does not affect
correctness. I don't do that in this patch, but will try in future.)

Diff Detail

Event Timeline

ruiu updated this revision to Diff 18217.Jan 15 2015, 1:12 AM
ruiu retitled this revision from to Run the resolver in parallel with the reader..
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a project: lld.
ruiu added a subscriber: Unknown Object (MLST).
shankarke accepted this revision.Jan 15 2015, 11:37 AM
shankarke edited edge metadata.
This revision is now accepted and ready to land.Jan 15 2015, 11:37 AM
atanasyan accepted this revision.Jan 16 2015, 7:13 AM
atanasyan edited edge metadata.

LGTM

atanasyan resigned from this revision.Feb 3 2016, 12:30 AM
atanasyan removed a reviewer: atanasyan.
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r226281.