Earlier today I released “FAKE – F# Make” version 1.10.0. This new release contains a lot path issue fixes for Mono and a new architecture for logging and tracing.
A guy named Joel Mueller had an awesome idea and sent me some patches. He noticed that TraceHelper.fs writes all messages synchronously to the console and/or a XML output file, which means the actual build operations must wait on the writing of hundreds of trace messages, slowing down the actual build.
His idea was to use a MailboxProcessor to buffer up the trace messages and write them out asynchronously, so that the actual build can proceed at full speed.
type Message =
{ Text : string
Color : ConsoleColor
Newline : bool
Important : bool}
/// ….
let buffer = MailboxProcessor.Start (fun inbox ->
let rec loop () =
async {
let! (msg:Message) = inbox.Receive()
match traceMode with
| Console -> logMessageToConsole msg
| Xml -> appendXML msg.Text
return! loop ()}
loop ())
Now all internal logging and tracing functions can post their their messages to the inbox of the MailboxProcessor:
/// Logs the specified string (via message buffer)
let logMessage important newLine message =
match traceMode with
| Console ->
{ Text = message;
Important = important;
Newline = newLine;
Color = ConsoleColor.White }
|> buffer.Post
| Xml ->
{ defaultMessage with
Text = sprintf "<message><![CDATA[%s]]></message>"
message }
|> buffer.Post
This idea reduces the build time of FAKE’s self build from 3 min. to 2 min. Which is really amazing, since I didn’t have to change anything in the build script. This version is compatible to the last released version.
Please download “FAKE – F# Make” version 1.10.0 and tell me what you think.
Tags: F#, F-sharp Make, Fake, performance