It seems like Phan isn't using 100% of it's CPU (saw 40%?) in the parse phase (but uses more in the analysis phase), probably due to spending a long time blocked on reading the file contents into memory.
Possible pseudocode (Not familiar enough with AMPHP to know if this will work, or if there's a cleaner way)
def fileReader(string[] fileNameList):
# yields a list of file contents and the corresponding file names.
BUF_SIZE = 4 # Simultaneously attempt to read at most this many files at a time.
filePromiseBuf = new Queue()
for fileName in fileList:
filePromise = Amp\File\read(fileName)
filePromiseBuf.push_back(filePromise)
if filePromise.length() >= BUF_SIZE()
yield filePromise.pop_front().wait() # missing error handling and file name
while not filePromiseBuf.empty():
yield filePromise.pop_front().wait()
It seems like Phan isn't using 100% of it's CPU (saw 40%?) in the parse phase (but uses more in the analysis phase), probably due to spending a long time blocked on reading the file contents into memory.
http://amphp.org/amp/promises/ and https://github.com/amphp/file (Still in alpha) seem like they may be used to asynchronously read files.
Possible pseudocode (Not familiar enough with AMPHP to know if this will work, or if there's a cleaner way)