Results 1 to 2 of 2

Thread: AMD Collocation Optimization

  1. #1
    bpolivka is offline Registered User
    Name: Brett Polivka
    Organization: Magnetar Capital
    Project: Financial Core Services
    Join Date
    Feb 2006
    Posts
    15

    AMD Collocation Optimization

    At our firm, we are currently using Ice to implement a number of financial service systems. We need to have a service locator that can differentiate between different versions, different locales, and different priorities. While we could implement our own locator service like the one provided with IceGrid, we would rather remove the dependency on a centralized service and employ a multicast locator strategy.

    I'm aware that this discussion has been brought up before, and I agree with you. This isn't something that should be bundled with Ice. As a result, I set out to implement my own Locator that I could plug into a Proxy/Communicator to implement the desired logic. Unfortunately, something that seems so simple turned out to be far more complex.

    Because this Locator is completely internal to the application and should not be reachable from outside of the process, I first created an unnamed ObjectAdapter with Communicator::createObjectAdapter(""). I registered an instance of my Locator implementation with it and got back my LocatorPrx proxy. I then created an indirect proxy to my service and set the locator to my proxy using ice_locator.

    The first problem I ran into was that Ice did not detect that the Locator proxy was local and kept failing because it could not find an endpoint. I traced this down to the ObjectAdapterI::isLocal method, where it attempts to find an adapter with endpoints that match the endpoints of the proxy. However, when the proxy has no endpoints (such as mine), it will always return false. By modifying the code to return true if a) it is a direct reference, b) it has no endpoints, and c) the adapter's id is empty, I was able to get Ice to correctly recognize my Locator proxy as local.

    The next problem I ran into was that not only is collocation not optimized for AMD methods, it's not implemented at all! Unfortunately, disabling collocation optimization doesn't work either, because as soon as it is disabled, Ice expects an endpoint to communicate over. Going back to my requirement that the Locator be internal and unreachable from outside the process, this isn't feasible.

    So, in my quest to get this working, I implemented collocation optimization for AMD methods for C++ and C#.

    It basically works by providing an alternate implementation of the AMD callback interface that uses a condition variable (Monitor on C#) to block the delegate method until the ice_response() method on the callback object has been called. The DelegateD method implementation constructs an instance of this interface and passes it to the <method>_async method of the servant. Upon returning from the servant call, the delegate will wait until the ice_response() method on the callback has been called (which may have happened in the <method>_async call). If the _async call needed to defer the response, the delegate will block, just as if it was a non-collocated call. Once ice_response() has been called (and the condition variable has been signaled), the delegate will resume and the return value and out params will be retrieved from the callback object and returned to the caller. The C++ version is futher optimized by constructing the callback object with references to the return value and out params that were passed in, and they will be filled out directly by the call to ice_response().

    With this in place, I was finally able implement my collocated Locator, and it works perfectly!!

    I've tried to write these patches in keeping with your style as much as possible, but given your intimate knowledge of the Ice internals, I wouldn't doubt if there is a better or cleaner way. I would absolutely love to see this implemented in the official release, as I really don't want to maintain a seperate set of patches. If you have any questions, or if there is anything I can do to help, please let me know.

    Thank you,
    Brett Polivka
    Attached Files Attached Files
    Brett Polivka
    Core Financial Systems
    Magnetar Capital LLC

  2. #2
    marc's Avatar
    marc is offline ZeroC Staff
    Name: Marc Laukien
    Organization: ZeroC, Inc.
    Project: The Internet Communications Engine
    Join Date
    Feb 2003
    Location
    Florida
    Posts
    1,860
    Thanks for the information. If you would like to have these patches integrated into future versions of Ice, please contact us at info@zeroc.com.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Proxy Colocation Optimization
    By tctimmeh in forum Help Center
    Replies: 3
    Last Post: 09-03-2008, 11:08 AM
  2. collocation optimization per object
    By jli125 in forum Help Center
    Replies: 1
    Last Post: 07-10-2007, 11:12 PM
  3. Collocation Optimization with IcePack: a bug?
    By zanza in forum Bug Reports
    Replies: 1
    Last Post: 07-01-2005, 05:48 AM
  4. Optimization for WIN32
    By hellocyf in forum Comments
    Replies: 3
    Last Post: 06-22-2004, 10:54 PM
  5. Replies: 3
    Last Post: 11-05-2003, 11:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •