Multiple selects() within a single VM

Is anyone aware of any contention issues when running multiple threads within a VM where each thread has it's own select statement?
I have an home grown app server that allows me to run multiple applications within a single VM. The applications are unrelated however they sometimes communicate with each other via TCP. All of them are very network intensive ( 500 messages a second where each message is around 200 bytes ). These apps are usually single threaded where the main thread is a select() loop.
Therefore, each application is a single threaded select() loop but there are multiple applications running within a single VM.
I am seeing performance issues when two apps running within the same VM try to send messages to one another via TCP. When the two apps are running on different boxes one app can send about 10,000 messages a second to the other app. However, when the apps are running within the same VM ( localhost TCP connection ) I can only transfer about 1000 messages a second.
Are 2 selectors running within the same VM a problem? Is it synchronized within the VM so that only one select can fire at a time?
I am running on a dual proc RH3 box with plenty of memory.
Any ideas?

Works for me, though I'm trying on Windows. Test program below. I get >10,000 replies and responses per second over loopback with both "java SelectPingPong both" (one VM) and running client and server on separate VMs.
Does this program get only 1000 messages/s on Linux? What VM version?
import java.util.*;
import java.net.*;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class SelectPingPong
    private static final int MESSAGE_SIZE = 200;
    private String server_name;
    private Selector selector;
    private HashMap clients = new HashMap();
    static class Client
     ByteBuffer buf = ByteBuffer.allocate(MESSAGE_SIZE);
     long connect_time = System.currentTimeMillis();
     int number_of_messages;
    public SelectPingPong(int port, String server_name)
     throws IOException
     this.server_name = server_name;
     selector = Selector.open();
     ServerSocketChannel server_channel = ServerSocketChannel.open();
     server_channel.configureBlocking(false);
     server_channel.socket().bind(new InetSocketAddress(port));
     server_channel.register(selector, SelectionKey.OP_ACCEPT);
    public Socket connect(String host, int port)
     throws IOException
     SocketChannel channel = SocketChannel.open();
     Socket socket = channel.socket();
     socket.connect(new InetSocketAddress(host, port));
     configureSocket(socket);
     channel.configureBlocking(false);
     channel.register(selector, SelectionKey.OP_READ);
     clients.put(channel, new Client());
     return socket;
    private void configureSocket(Socket socket)
     throws IOException
     // Let's say we have a request-reply protocol with modest requirements
     socket.setReceiveBufferSize(1024);
     socket.setSendBufferSize(1024);
    public void mainLoop()
     while (true) {
         try {
          selector.select();
          for (Iterator iter = selector.selectedKeys().iterator(); iter.hasNext(); ) {
              SelectionKey key = (SelectionKey) iter.next();
              iter.remove();
              if (!key.isValid())
               continue;
              if (key.isAcceptable())
               acceptClient(key);
              if (key.isReadable())
               readFromClient(key);
         } catch (Exception e) {
          System.out.println(server_name + ": error in selector loop: " + e);
          e.printStackTrace();
    private void acceptClient(SelectionKey key)
     throws IOException
     ServerSocketChannel server_channel = (ServerSocketChannel) key.channel();
     if (server_channel == null)
         return;
     SocketChannel channel = server_channel.accept();
     if (channel == null)
         return;
     configureSocket(channel.socket());
     channel.configureBlocking(false);
     channel.register(selector, SelectionKey.OP_READ);
     clients.put(channel, new Client());
     System.out.println(server_name + ": got a new client; " +
                  clients.size() + " clients");
    private void readFromClient(SelectionKey key)
     throws IOException
     SocketChannel channel = (SocketChannel) key.channel();
     Client client = (Client) clients.get(channel);
     ByteBuffer buf = client.buf;
     int count;
     try {
         count = channel.read(buf);
     } catch (IOException e) {
         System.out.println(server_name + ": error reading, closing connection: " + e);
         clients.remove(channel);
         channel.close();
         return;
     if (count == -1) {
         clients.remove(channel);
         System.out.println(server_name + ": client disconnected; " +
                      clients.size() + " clients");
         channel.close();
         return;
     if (buf.position() == MESSAGE_SIZE) {
         if (++client.number_of_messages % 10000 == 0) {
          long now = System.currentTimeMillis();
          System.out.println(server_name + ": " + client.number_of_messages +
                       " messages in " + (now - client.connect_time) + " ms");
         buf.flip();
         // RFE write without blocking
         writeFully(channel, buf);
         buf.rewind();
    public static void writeFully(SocketChannel channel, ByteBuffer buf)
     throws IOException
     while (buf.remaining() != 0)
         channel.write(buf);
    private static void startClient()
     throws Exception
     SelectPingPong client = new SelectPingPong(6667, "client");
     Socket socket = client.connect("localhost", 6666);
     // Send initial message
     ByteBuffer buf = ByteBuffer.allocate(MESSAGE_SIZE);
     buf.put(new byte[MESSAGE_SIZE]);
     buf.flip();
     socket.getChannel().write(buf);
     client.mainLoop();
    public static void main(String args[])
     throws Exception
     if (args.length == 1 && args[0].equals("server")) {
         SelectPingPong server = new SelectPingPong(6666, "server");
         server.mainLoop();
     } else if (args.length == 1 && args[0].equals("client")) {
         startClient();
     } else if (args.length == 1 && args[0].equals("both")) {
         new Thread() { public void run() {
          try {
              SelectPingPong server = new SelectPingPong(6666, "server");
              server.mainLoop();
          } catch (Exception e) {
              System.err.println("error in server");
         } }.start();
         startClient();
     } else {
         System.err.println("usage: SelectPingPong [client | server | both]");
}

Similar Messages

  • Multiple subreports within a single main report?

    I'm a newbie to BI Publisher, but have used Crystal Reports quite a lot.
    I have a requirement which essentially consists of a set of 7 similar and closely related reports, each using a different SQL Select statement and printing different columns; the user will have the option of selecting either one of the 7, or all of them.
    In Crystal Reports I would set up 7 subreports within a single main report, and depending on the parameter, suppress those subreports which are not required.
    Is there a technique within BI Publisher which would enable me to achieve the same thing?

    all the sub templates will go against a single XML. So if your sub reports in CR is handling different query, you need to take a step back and think of separating data and layout. So multiple queries will be handled by data templates. So, for example, if your main report fetches some records as Q1 query, and you have two sub templates with queries as SQ1, SQ2 (linked subreport). Then we have to see what relationship exists between the main report and the subreport. Say, the sub report query creates a relationship with the Main report data, to filter certain records. So this can be achieved in data template using Q1 and SQ1 using bind relationship, ie, Q1 is master query and SQ1 is a detail query. Similarly Q1 and SQ2 relationship can be established. The datatemplate when executed, will fetch a single XML data.So in this case you do not need sub template. The sub-report layout is not separate, and is to be created with the main report.
    In case of unlinked subreport, the content of subreport is independent of main report, so you can simply define two datasets in BI Publisher and then select the Concatenation option. So the final XML data will be a concatenation of two XML data. The main report can read data of the main XML and the sub template can read data from the appended XML data. This can be done using xPath.

  • Multiple selection but delete single item

    Hi,
    please help me to find a solution!!
    I have 2 listboxes. listbox Description is populated by XML.
    When user selects multiple items at the same time from the Description listbox, they are populated in the listbox and are removed from Description listbox. that works fine.
    But the issue is if the user accidently selects one of the multiple selected items at the same time wrong and want to delete a single items, this doesnt work anymore.
    I can not even click on each single item.
    I try to find a way how to enable user to populate multiple items at the same time and be able to delete each single item, which then should return back to the Description listbox.
    I would really appreciate if you could help me on this!!!
    This is my sample: https://acrobat.com/#d=l0mujTOFduSJFele5R5i3g
    Thanks,
    Diana

    Would you not just reverse your code ..instead of populating listbox from the selections in description and deleting the items out of description, remove the items from listbox and update description then remove the items from listbox.
    Or am I missing something?
    Paul

  • Multiple Selection Property in Single Column Listbox

    Hello All,
    I have taken a Single-column list box and have enable the multiple selection property of the listbox.
    In fact, i want to find out the values of the multiple rows selected in the listbox. But, i couldn't found any of the property of this listbox that can indicate the index or value of the multiple lines that are selected.
    Can anybody help me to resolve this issue? What is the approach i can take to find out the multiple rows selected in the listbox?
    Regards,
    Nishant

    Nishant wrote:
    Hello All,
    I have taken a Single-column list box and have enable the multiple selection property of the listbox.
    In fact, i want to find out the values of the multiple rows selected in the listbox. But, i couldn't found any of the property of this listbox that can indicate the index or value of the multiple lines that are selected.
    Can anybody help me to resolve this issue? What is the approach i can take to find out the multiple rows selected in the listbox?
    Regards,
    Nishant
    Here is an example where the value is read from a property node.
    the Value becomes an array when you elect a selection mode that allows multiple selections. (and thats the reason you can't write Selection mode while the VI is running
    Jeff
    Attachments:
    Listbox.vi ‏7 KB

  • Multiple Selects in a single form

    I have six select boxes and I want them in a single form.
    Below are the outputs for the select boxes.
    <cfform
    action="Resolution_History.cfm?year=#year#&sessiontype=#sessiontype#&btype=res"
    name="form">
    <select name="SRINPUT">
    <option value="">SR
    <CFOUTPUT Query="findSR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="HRINPUT">
    <option value="">HR
    <CFOUTPUT Query="findHR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="SCRINPUT">
    <option value="">SCR
    <CFOUTPUT Query="findSCR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <br>
    <select name="HCRINPUT">
    <option value="">HCR
    <CFOUTPUT Query="findHCR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="SJRINPUT">
    <option value="">SJR
    <CFOUTPUT Query="findSJR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <select name="HJRINPUT">
    <option value="">HJR
    <CFOUTPUT Query="findHJR"><Option
    Value="#BILLNUMBER#">#BILLNUMBER#</cfoutput>
    </select>
    <INPUT TYPE="Submit" VALUE="Submit" alt="submit
    button">
    </cfform>
    Once a user selects a number it will send them to an action
    page. On the action page I need the below IF statement to work so
    it will set the variables. It isn't working at this time. Its not
    bringing the values of billnumber, houseorig or the billtype.
    Does anyone have any thoughts? I know it is close to working
    and I need to set all of the inputs to input4 to generate my
    queries so I don't have to duplicate them.
    <cfif form.srinput gt "0">
    <cfset s = '#houseorig#'>
    <cfset r = '#billtype#'>
    <cfset input4 = '#srinput#'>
    <cfelseif form.hrinput gt "0">
    <cfset h = '#houseorig#'>
    <cfset r = '#billtype#'>
    <cfset input4 = '#hrinput#'>
    <cfelseif form.scrinput gt "0">
    <cfset s = '#houseorig#'>
    <cfset cr = '#billtype#'>
    <cfset input4 = '#scrinput#'>
    <cfelseif form.hcrinput gt "0">
    <cfset h = '#houseorig#'>
    <cfset cr = '#billtype#'>
    <cfset input4 = '#hcrinput#'>
    <cfelseif form.sjrinput gt "0">
    <cfset s = '#houseorig#'>
    <cfset jr = '#billtype#'>
    <cfset input4 = '#sjrinput#'>
    <cfelse>
    <cfset h = '#houseorig#'>
    <cfset jr = '#billtype#'>
    <cfset input4 = '#hjrinput#'>
    </cfif>

    give'em a break. he is probably under pressure (like we all
    have been). in response, i do not even see some of the variables
    you are checking in the second script in the first. get this one
    straight and i think it'll work.

  • How to filter with multiple selection on a single column on external list, currently only one filter per column is available.

    I have external list where i want to apply multiple filter for every column like we do in Excel spreadsheet - we can filter a spreadsheet column by selecting multiple checkbox for every  column. I am using Sharepoint 2010
    Is this possible in sharepoint 2010? Any idea how to acheive that?
    Thanks in advance.

    Hi Rahul,
    According to your description, my understanding is that you want to use filter with multiple values on a column of an external list in SharePoint 2010.
    Per my knowledge, there is not an OOB way to achieve it. As a workaround, you can custom the web part to implement it. There is an articles for your reference:
    http://blogs.telerik.com/aspnet-ajax/posts/13-11-05/add-excel-like-multi-select-filtering-to-your-asp.net-datagrid
    In addition, you can use a third party solution to achieve it, please take a look at:
    http://abilitics.com/Blog/index.php/sharepoint-improved-grids-with-excel-like-inline-editing/
    http://social.technet.microsoft.com/forums/sharepoint/en-US/3d19b9d3-d394-4af9-9e8e-2dee70b50540/filter-column-with-multiple-filter-values-in-sharepoint-list
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Multiple columns within a single text frame

    Is it at all possible to make a single text frame containing first a single column followed by two columns?
    Why: I need to have my heading expanding across my two column body text. What's important is that I need the two column body text to automatically drop whenever I type (or paste) in more text in my heading. Like it would if the heading and body text was in a single column.
    My text frame options (I work in CS3) do not give me this option, I can only work in one "frame set". I have tried fixing this problem with combinations of tables, multiple text frames and text wrap, but nothing really works.

    Thank you Peter.
    Yes I did try it.
    InDesign CS3 just gives me this alert:
    I also tryed copying the files (HeadStraddler.jsx and HeadStraddler.indl) into a folder like you suggested.
    C:\Program Files\Adobe\Adobe InDesign CS3\Scripts\Scripts Panel\Version 4.0 Scripts\HeadStraddlerForCS2.
    But I just get the same alert.

  • Multiple Formats within a Single Form Field

    I really could use some help with this one...
    In a fairly simple pdf form I've created I need a field that handle text and currency formatting....within the same field.  Is this possible?  If so, can you provide the code for this situation?
    Thanks!

    If you have the freedom to change the design/layout, I'd suggest adding a check box to indicate N/A. You can set up the check box to clear the amount field and make it read-only.
    If that's not going to happen, what you want to do is possible, assuming that if the value of the field is a valid number then format it with that currency format, and nothing otherwise. This will require a custom format script. Post again if you really want to go with this approach.

  • I'm having problems transfering audiobooks to my iPod touch 5th Gen with the latest software upgrade.  It combines 2 books under the same title giving me multiple chapters within the single title.

    When I transfer audiobooks to my touch, I sometimes get a new book transferred that shows up correctly in iTunes but when I open music on the iPod, I have a single book title with both volumes under it.  I end up with 2 Chapters 1, 2 Chapters 2, etc.  Anyone else have this problem?

    Well, I decided to try working at it from the Windows side because I was getting absolutely nowhere using iTunes in OS X. Strangely enough it just worked like it's supposed to this time when I loaded up iTunes in Vista. (I tried before in Vista, with the same problem occurring).
    No idea why it worked... I hadn't even authorized iTunes in Vista to play tracks registered to my iTMS account.
    If anyone can offer any help from the Mac side, it would be much appreciated. I only have a few specific reasons for using Vista... would prefer if I could avoid restarting into it just to change a few things on my iPod.

  • CS4-connecting to multiple tables within a single Indesign doc.

    Hi!
    I recently downloaded Datalinker, a plugin for Indesign that lets you connect to databases. I created a table in indesign and pulled in data from one table in the database. The problem I'm having is if I create another table in the same indesign document and want to access a different table in the database, I can't get that to work. It seems like it only wants to be able to connect to one table at a time per document?
    Does anyone know a different way to go about doing this?
    Thanks!

    Have you contacted Teacup? They're very good about responding.
    Bob

  • Adobe captivate multiple quizzez within a single project

    Hello I am trying to create a test that includes 6 different exams, but i want the usert to have to pass each exam with at least a 75% before they can access the next quiz. I am very new to captivate. Any help would be very appreciated.
    Thank you

    You will need 6 different Captivate projects, each of which will have one quiz (exam).  You can set the passing percentage for each project file to 75% under Quiz Settings > Pass Fail.  To force the user to pass each module of your course before they can do the next one, you really need to be serving up your course content via a Learning Management System.  The LMS usually handles that side of it.  If packaging your course modules as a multi-SCO SCORM course for your LMS, you'll ideally be using Adobe's Elearning Suite 6, which comes with the Multi-SCORM Packaging tool.  The version that comes with ELS 6 can accommodate more of the SCORM rules than previously possible in earlier versions.

  • Multiple people using multiple select list

    Hi,
    First of all, let me congratulate Oracle HTML DB for bringing such a great product. It is extremely powerful, and useful.
    I have multiple people using a form which has multiple selects in it and calls an Oracle report. I looked at couple of examples and I couldn’t understand how IDs work in this scenario. It is not clear if I need to create an id on HTML DB side or on the Oracle reports side or at the database level. Obviously, if people delete or select each others selected parameters, it is a big issue. Could you please explain me about how this is achieved.

    The touch ID is only for accessing the device, no log is kept, and no apps can access its details.
    You can create multiple fingerprints within a single device so more than 1 person could access it, but there is no detail of who accessed it or when.
    You may be better served looking at a portable time clock device that uses RFID cards for login and out or similar to this
    http://www.mjobtime.com/default.aspx?source=adwords&kw=portable+time+clock&gclid =CLWz2Pat18ACFSsV7AodCTsALQ

  • How to test for différent Select into a single PL/SQL block ?

    Hi,
    I am relatively new to PL/SQL and I am trying to do multiple selects int a single PL/SQL block. I am confronted to the fact that if a single select returns no data, I have to go to the WHEN DATA_NOT_FOUND exception.
    Or, I would like to test for different selects.
    In an authentification script, I am searching in a table for a USER ID (USERID) and an application ID, to check if a user is registered under this USERID for this APPLICATION.
    There are different possibilities : 4 possibilities :
    - USERID Existing or not Existing and
    - Aplication ID found or not found for this particular USERID.
    I would like to test for thes 4 possibilities to get the status of this partiular user regardin this application.
    The problem is that if one select returns no row, I go to the exception data not found.
    In the example below you see that if no row returned, go to the exception
    DECLARE
    P_USERID VARCHAR2(400) DEFAULT NULL;
    P_APPLICATION_ID NUMBER DEFAULT NULL;
    P_REGISTERED VARCHAR2(400) DEFAULT NULL;
    BEGIN
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
    :P39_TYPE_UTILISATEUR := 'USER_REGISTERED';
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND';
    END;I would like to do first this statement :
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID Then to do this one if the user is found :
    SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
    WHERE  USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;etc...
    I basically don't want to go to the not found exception before having tested the 4 possibilities.
    Do you have a suggestion ?
    Thank you for your kind help !
    Christian

    Surely there are only 3 conditions to check?
    1. The user exists and has that app
    2. The user exists and doesn't have that app
    3. The user doesn't exist
    You could do this in one sql statement like:
    with mimic_data_table as (select 1 userid, 1 appid from dual union all
                              select 1 userid, 2 appid from dual union all
                              select 2 userid, 1 appid from dual),
    -- end of mimicking your table
             params_table as (select :p_userid userid, :p_appid appid from dual)
    select pt.userid,
           pt.appid,
           decode(min(case when dt.userid = pt.userid and dt.appid = pt.appid then 1
                           when dt.userid = pt.userid then 2
                           else 3
                      end), 1, 'User and app exist',
                            2, 'User exists but not for this app',
                            3, 'User doesn''t exist') user_app_check
    from   mimic_data_table dt,
           params_table pt
    where  pt.userid = dt.userid (+)
    group by pt.userid, pt.appid;
    :p_userid = 1
    :p_appid = 2
        USERID      APPID USER_APP_CHECK                 
             1          2 User and app exist   
    :p_userid = 1
    :p_appid = 3
        USERID      APPID USER_APP_CHECK                 
             1          3 User exists but not for this app
    :p_userid = 3
    :p_appid = 2
        USERID      APPID USER_APP_CHECK                 
             3          2 User doesn't exist  

  • Multiple sessions in a single database connection.

    I have copied the following text from Forms Developer2000
    "At runtime, Form Builder automatically establishes and manages a single connection to ORACLE. By default, one user session is created for this connection. However, the multiple-sessioning feature of ORACLE allows a single client to establish multiple sessions within a single connection. ORACLE transaction-management and read-consistency features all are implemented at the session level, so creating multiple sessions allows a single user to have multiple, independent transactions."
    If ORACLE allows a single client to establish multiple sessions within a single connection, I want to leverage on this feature in my application which uses BC4J.
    Can anybody tell me if
    1. its possible achieve this in Java(BC4J).
    2. If Yes, How?
    regards,
    vikrant

    Thank you for your valuable suggestion.
    I believe createing multiple root Application
    Modules, will create as many number of connections to
    database, hence multiple transactions.
    But What I wanted was multiple sessions in a single
    connection, who's behavior will be similar to two
    different connections.Could you tell me the advantage you're looking for in multiple sessions in one connection vs. multiple connections (where connections may be pooled)?
    Thanks.
    Sung

  • Submitting multiple tasks within a job?

    So far I have been submitting scripts/commands to my grid which execute as single tasks. I want to learn how to submit multiple tasks within a single submitted job. Does anyone know a good reference to learn this topic? I tried the man pages but I would like something less cryptic to read.

    So far I have been submitting scripts/commands to my grid which execute as single tasks. I want to learn how to submit multiple tasks within a single submitted job. Does anyone know a good reference to learn this topic? I tried the man pages but I would like something less cryptic to read.

Maybe you are looking for

  • Sync a second mac to iCloud Photo library

    Hey guys. I have uploaded the entire photo library from mac 1. I want the same library on mac 2 but I don't want to download the entire 80gig. Does anyone know what would happen if I transfer the library via usb to the second mac ? Would it upload a

  • In C# is there a way of refreshing query in EXCEL (REFRESH ALL)

    Hi All, Need C# code in SSIS Sript task which should refresh all excel data which extracts from a table using Microsoft query. Can anyone help at all ? Thanks  Sri.Tummala

  • Does anyone else have a problem with Picture Messaging?

    Everything works just fine... except when i try to send a pic msg. It starts to send but then it has a little red exclamation point by the picture and the picture fails to send.

  • Combine two iTunes Libraries...

    All, I have an iMac G5 @ work and a PowerBook G4 @ home. Each has an iTunes library. Short question...Is there any way for me to get my music off of my iMac and onto my PowerBook? I plan to use my external FW HD drive to make the move. Details...In a

  • How sales order gets shipping date

    Dear all, Please tell me how to get these vales in sales order/Schedule line/Shipping. Delivery date             D         2010/11/16 Goods issue date                 2010/11/15 Loading date                         2010/11/12 Material avail.date