Monday, April 27, 2015

souping thinkorswim: run two instances.

you can run two instances of the thinkdesktop from the same computer. that is, i run a second thinkdesktop and log-in twice. two is permitted by the tda servers but i think a 3rd instance will trigger a failure.  i just tried this today from a single laptop and it worked great. on one instance i had all my normal gadgets, watchlists w. custom columns, charts, studies and strategies running. on the second instance i deleted all gadgets, watchlists and displayed no charts - but i ran the shadow trader presentation from this second instance.

previously, i ran all this stuff including the shadow trader presentation from a single instance and was getting pesky long pauses when the garbage collector ran. my observations of the task manager during these gc-pauses revealed that one of my dual cpu's was running flat-out while the other one was idle - giving the misimpression of a non-constrained cpu resource (50% idle.) research on oracle's website revealed some interesting facts about the java garbage collecter that led me to this dual- instance experiment:

  1. the java heap does not maintain a linked-list of free memory blocks. free memory is one contiguous block that is doled out as requested.
  2. the more objects in use the longer the gc takes to run. this is because there is no freelist. instead, the gc performs a tree-search of live objects, marking them as it sweeps through the list, then, infers that anything not marked as 'alive' is trash. the more live objects there are, the longer this takes.
  3. trash compaction is part of every gc run. again, because there is no free-list, all live objects are moved around so that the free memory is one contiguous space at the end of a gc run. this might put a write-load on the page-file but that is why i went with the solid state disk.
  4. the garbage collector is single threaded. no matter how many concurrent threads the application codes for, the gc is mostly a single threaded affair that puts all application threads into suspension while it runs. this explains why i see one cpu pinned-out while the other is idle.
so now, with the dual tos instances, i have two heaps and the possibility of dual garbage collection with fuller cpu utilization. each heap has fewer live objects to contend with, so the gc-pauses are much smaller - and at least i can listen to brad agunas while i am waiting.


  1. this is brilliant.

  2. Looks like you can do more than two! I just logged into 4 separate sessions (after hours) and didn't get any error messages. My machine has 4 cores and 4 screens so I'm going to try this for trading tomorrow and see if I notice any performance difference. Up until now I've just been using 1 instance with 4 detached trading windows.

  3. yeah we're looking into separate accounts. with that aspect one should be able to run one instance for each account trading a different set of pairs (forex). we trade 24 pair so it oughta work out perfectly. this would be on a single computer running linux.


Note: Only a member of this blog may post a comment.