Skip to content

Commit

Permalink
set min worker pool to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
akissinger committed May 24, 2014
1 parent 846be74 commit cf7b89b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
32 changes: 16 additions & 16 deletions core/json_interface/protocol.ML
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ end
fun version _ = Json.String "2.1"

fun dispatch systemf rid json = let
val _ = Log.log 2 "(core) dispatch\n"
val _ = Log.log 2 "(core) dispatch"
val controller = arg_str json "controller"
val module = arg_str json "module"
val function = arg_str json "function"
val _ = Log.log 2 ("(core) got dispatch " ^ controller ^ "::" ^ module ^ "::" ^ function ^ "\n")
val _ = Log.log 2 ("(core) got dispatch " ^ controller ^ "::" ^ module ^ "::" ^ function)
val json_input = case optarg_json json "input" of SOME x => x | NONE => Json.mk_object []
val json_output =
Json.mk_object [
Expand All @@ -68,7 +68,7 @@ fun dispatch systemf rid json = let
]
handle user_exn msg => json_error rid 0 msg
| protocol_exn msg => json_error rid ~1 msg
val _ = Log.log 2 "(core) dispatch worker finished\n"
val _ = Log.log 2 "(core) dispatch worker finished"
in
json_output
end
Expand Down Expand Up @@ -129,46 +129,46 @@ let
| system _ _ = raise user_exn ("Unrecognized system function. (options: help, kill, version)")

fun push_output json = (
Log.log 2 "(core) push_output: waiting for lock\n";
Log.log 2 "(core) push_output: waiting for lock";
Mutex.lock output_lock;
Log.log 2 "(core) push_output: obtained lock\n";
Log.log 2 "(core) push_output: obtained lock";
output_buffer := (json :: !output_buffer);
ConditionVar.broadcast has_output;
Mutex.unlock output_lock;
Log.log 2 "(core) push_output: released lock\n"
Log.log 2 "(core) push_output: released lock"
)
fun flush_all buf = fold_rev (fn json => fn () => TextIO.output (outstream, Json.encode json)) buf ()
fun output_loop () = (
Log.log 2 "(core) waiting for lock on output loop\n";
Log.log 2 "(core) waiting for lock on output loop";
Mutex.lock output_lock;
Log.log 2 "(core) obtained lock on output loop\n";
Log.log 2 "(core) obtained lock on output loop";
if List.null (!output_buffer) then ConditionVar.wait (has_output, output_lock) else ();
if List.null (!output_buffer) then () else Log.log 2 "writing output";
flush_all (!output_buffer);
output_buffer := [];
Mutex.unlock output_lock;
Log.log 2 "(core) released lock on output loop\n";
Log.log 2 "(core) released lock on output loop";
TextIO.flushOut outstream;
output_loop ()
)

fun input_loop src =
let
val _ = Log.log 2 "(core) waiting for request on input loop\n"
val _ = Log.log 2 "(core) waiting for request on input loop"
val (json_list, src') = Source.get src
val _ = Log.log 2 "(core) got request\n"
val _ = Log.log 2 "(core) got request"
val json = case json_list of [x] => x | _ =>
raise protocol_exn "Expected: exactly one JSON object"
val rid = arg_int json "request_id"
val _ = Log.log 2 "(core) preparing to update job table\n"
val _ = Log.log 2 "(core) preparing to update job table"
val _ = Synchronized.change job_table (fn tab => (
Log.log 2 "(core) updating job table\n";
Log.log 2 "(core) updating job table";
if IntName.NSet.contains (JobTable.get_dom_set tab) rid
then (push_output (json_error rid 0 "Duplicate request ID"); tab)
else
let
val _ = Log.log 2 "(core) forking new worker\n"
val worker = Future.fork (fn () => (Log.log 2 "(core) worker forked\n"; dispatch system rid json))
val _ = Log.log 2 "(core) forking new worker"
val worker = Future.fork (fn () => (Log.log 2 "(core) worker forked"; dispatch system rid json))
in Thread.fork (fn () => (
let
val json = PolyML.exception_trace (fn () => (
Expand All @@ -185,7 +185,7 @@ let
in input_loop src'
end
in (
Log.log 2 "(core) forking output loop\n"; Thread.fork (output_loop,[]);
Log.log 2 "(core) forking output loop"; Thread.fork (output_loop,[]);
input_loop (Json.json_source instream)
)
end
Expand Down
2 changes: 2 additions & 0 deletions core/run_protocol.ML
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PolyML.SaveState.loadState "heaps/quanto.heap";
PolyML.Compiler.printDepth:=100;

(* Futures may hang unless we allow at least 4 workers *)
if (!Multithreading.max_threads <= 4) then Multithreading.max_threads := 4 else ();

fun run_protocol port () =
let
Expand Down
8 changes: 4 additions & 4 deletions scala/dist/windows-dist/QuantoDerive.aip
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DOCUMENT Type="Advanced Installer" CreateVersion="11.0" version="11.0" Modules="simple" RootPath="." Language="en" Id="{6220F12D-600C-49A6-84D3-25E6A6C175E6}">
<DOCUMENT Type="Advanced Installer" CreateVersion="11.0" version="11.2" Modules="simple" RootPath="." Language="en" Id="{6220F12D-600C-49A6-84D3-25E6A6C175E6}">
<COMPONENT cid="caphyon.advinst.msicomp.MsiPropsComponent">
<ROW Property="AI_BITMAP_DISPLAY_MODE" Value="0"/>
<ROW Property="ALLUSERS" Value="1"/>
<ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
<ROW Property="ARPPRODUCTICON" Value="quantoderive.exe" Type="8"/>
<ROW Property="ARPURLINFOABOUT" Value="http://quantomatic.github.io/"/>
<ROW Property="Manufacturer" Value="Quantomatic"/>
<ROW Property="ProductCode" Value="1033:{95A16B60-32CD-4C6C-830C-BE040483AD0E} " Type="16"/>
<ROW Property="ProductCode" Value="1033:{4A02FD4E-EEBE-4E97-8EAA-846DBC55451A} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="QuantoDerive"/>
<ROW Property="ProductVersion" Value="0.2.0" Type="32"/>
<ROW Property="ProductVersion" Value="0.3.1" Type="32"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
<ROW Property="UpgradeCode" Value="{EEBC04E2-4BE2-42F4-B9EA-09453144B787}"/>
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>
Expand Down Expand Up @@ -121,7 +121,7 @@
<ROW Dialog_="VerifyReadyDlg" Control_="Back" Event="NewDialog" Argument="PatchWelcomeDlg" Condition="AI_PATCH" Ordering="203"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiCreateFolderComponent">
<ROW Directory_="SHORTCUTDIR" Component_="SHORTCUTDIR"/>
<ROW Directory_="SHORTCUTDIR" Component_="SHORTCUTDIR" ManualDelete="false"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiCustActComponent">
<ROW Action="AI_DOWNGRADE" Type="19" Target="4010"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ case class StreamMessage(parts: MessagePart*) {
}

def writeTo(out: OutputStream) {
writeTo(new OutputStreamWriter(out))
writeTo(new OutputStreamWriter(out, "ISO-8859-1"))
}

def stripCodes = parts.filter{ case _: CodePart => false ; case _ => true }
Expand Down

0 comments on commit cf7b89b

Please sign in to comment.