SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
Java IPC
And the CLIP Library
      Clark N. Hobbie
  Long Term Software, LLC
    clark.hobbie@ltsllc.com
Who Gives a Damn?
You Should Care Because…
•   If you are in a corner
•   Java sync is one VM only
•   Others require JNI
•   Platform differences




3/3/2009          http://ltsllc.com/slides/ipc.html   3
What Are the Options?
•   Sockets
•   Message Queues
•   Semaphores
•   Shared Memory




3/3/2009         http://ltsllc.com/slides/ipc.html   4
Which Option Should I Use?
Shared Memory
•   JRE support
•   Highest bandwidth
•   Decent synchronization
•   Naming support



3/3/2009         http://ltsllc.com/slides/ipc.html   5
Why Should I Care about CLIP?
• New primitives
     – Semaphores
     – Message Queues
• Simplifies existing primitives
     – Shared Memory




3/3/2009         http://ltsllc.com/slides/ipc.html   6
Java

RandomAccessFile raf = new RandomAccessFile(quot;/temp/smfilequot;, quot;rwquot;);
FileChannel chan = raf.getChannel();
MappedByteBuffer buf = chan.map(MapMode.READ_WRITE, 0, size);
byte[] other = new byte[1024];
buf.position(0);
buf.get(other, 0, 1024);




3/3/2009               http://ltsllc.com/slides/ipc.html         7
CLIP

SharedMemory smem =
           new SharedMemory(quot;/temp/smfilequot;);




3/3/2009            http://ltsllc.com/slides/ipc.html   8
What is IPC?
Inter-Process Communication (IPC)
•   Multiple processes
•   Naming
•   Synchronization
•   Bandwidth



3/3/2009         http://ltsllc.com/slides/ipc.html   9
Naming

           Me Tarzan,
           who you?




3/3/2009          http://ltsllc.com/slides/ipc.html   10
Naming
How do you…
• Connect processes together?
• Determine who is allowed to connect?
• Examples
     – TCP/IP?
     – Email?
     – Telephones?


3/3/2009             http://ltsllc.com/slides/ipc.html   11
File Naming
Many IPC methods use the file system
because
• Visible to all processes
• Has access control built in




3/3/2009      http://ltsllc.com/slides/ipc.html   12
File Naming Examples
• Memory Mapped Files
• Named Pipes/FIFOs




3/3/2009        http://ltsllc.com/slides/ipc.html   13
Synchronization
•      Event ordering
•      Mutual exclusion




3/3/2009          http://ltsllc.com/slides/ipc.html   14
Example: Online Purchase
1. Get user credit information
2. Decision purchase
3. Update credit information




3/3/2009          http://ltsllc.com/slides/ipc.html   15
Without Event Ordering
       Client A                                         Client B
1 Get credit info
                                      2 Get credit info
2 Decision purchase
3 Update info
                                      4 Decision purchase
                                      5 Update info


3/3/2009            http://ltsllc.com/slides/ipc.html              16
With Event Ordering
       Client A                                         Client B
1 Get credit info
                                      2 Wait for A
2 Decision purchase
3 Update info
                                      4 Get credit info
                                      5 Decision purchase
                                      6 Update info

3/3/2009            http://ltsllc.com/slides/ipc.html              17
Synchronization is Event Ordering
Instead of this order:               We want this order:
•   A gets credit info               •    A gets credit info
•   B gets credit info               •    A decisions purchase
•   A decisions purchase             •    A updates info
•   A updates info                   •    B gets credit info
•   B decisions purchase             •    B decisions purchase
•   B updates credit info            •    B updates credit info


3/3/2009           http://ltsllc.com/slides/ipc.html          18
Which Type of IPC is Appropriate?




3/3/2009    http://ltsllc.com/slides/ipc.html   19
IPC Types
•   Shared Memory
•   Semaphores
•   Sockets
•   Message Queues




3/3/2009       http://ltsllc.com/slides/ipc.html   20
Shared Memory




3/3/2009     http://ltsllc.com/slides/ipc.html   21
Shared Memory
•   Preferred approach
•   Any to any
•   get/put semantics
•   Synchronization support
•   JRE support
•   Naming support


3/3/2009         http://ltsllc.com/slides/ipc.html   22
Shared Memory Details
• Synchronization
     – File Locking
     – Lock/unlock ~ 25 usec
• Naming
     – File naming
• Bandwidth
     – Synchronized 250MB/sec
     – Unsynchronized 1000MB/sec
3/3/2009             http://ltsllc.com/slides/ipc.html   23
Memory Mapped Files
• Start with a file
     – Appears the same to everyone
     – Reads/writes appear to everyone
• Now speed it up
     – Until its as fast as memory
     – Like having the OS buffer



3/3/2009            http://ltsllc.com/slides/ipc.html   24
Why Dear God, Why?!!
• Originally Unix
     – Where everything is a file
     – mmap system call
     – CreateFileMapping system call
• Solves the naming problem
• Solves the access problem



3/3/2009           http://ltsllc.com/slides/ipc.html   25
Example: World of Warcraft!


                                                  Shared Memory!




3/3/2009      http://ltsllc.com/slides/ipc.html                    26
WoW: Requirements
•   One client process per player
•   One server process for all
•   Server periodically reads all orders
•   Server issues results




3/3/2009          http://ltsllc.com/slides/ipc.html   27
WoW: Design

       Client
                             Orders
     (EvilOne)

                   Player                 Order

                  EvilOne                 kill
      Client      Lancelot                kill
    (Lancelot)                                          Client
                  Martha Stewart        kill
                                                       (Conan)
                  Conan                make cookies
                  …


      Client
     (Martha)




3/3/2009           http://ltsllc.com/slides/ipc.html             28
WoW: Design

                                                                                Results
            Orders
                                            Server
                                            Process                   Player              Result
   Player            Order
                                                                     EvilOne              dead
 EvilOne             kill
                                                                     Lancelot
 Lancelot                                                                                 dead
                     kill
                                                                     Martha Stewart
 Martha Stewart                                                                         dead
                   kill
                                                                     Conan            overweight
  Conan           make cookies
                                                                     …
  …




3/3/2009                         http://ltsllc.com/slides/ipc.html                                 29
Shared Memory: Summary
•   Preferred IPC
•   250 to 1000MB/sec
•   File naming
•   Synchronization through file locking
•   JRE support




3/3/2009          http://ltsllc.com/slides/ipc.html   30
Sockets




3/3/2009   http://ltsllc.com/slides/ipc.html   31
Sockets
•   TCP/IP
•   Point to point
•   Stream oriented
•   Client/Server
•   Synchronized
•   Java support
•   Naming support

3/3/2009         http://ltsllc.com/slides/ipc.html   32
Sockets Details
• Naming
     – 127.0.0.1 port 7777
• Synchronization
     – Accept, read, write
     – 70 usec
• Bandwidth
     – 15 MB/sec


3/3/2009            http://ltsllc.com/slides/ipc.html   33
Sockets: CLIP
• Some utility classes
     – ThreadedSocketServer
• JRE already has excellent support




3/3/2009          http://ltsllc.com/slides/ipc.html   34
Example: Google Maps




                         Copyright © Google


3/3/2009        http://ltsllc.com/slides/ipc.html   35
GMaps
                   Combining Data
                                                         Streets
           Image




                                Overlay




                                                          Images are Copyright ©
                                                          www.Google.com




3/3/2009             http://ltsllc.com/slides/ipc.html                             36
GMaps: Requirements
•   C legacy code
•   One instance/process
•   Receive file name
•   Process for 1 to 10 sec
•   Respond with new file name




3/3/2009        http://ltsllc.com/slides/ipc.html   37
GMaps: Design

                                                                  Worker Pool
           Server Process

               Java VM


              Client                                                Client
               Client                                                Client
                 Client                                                Client
                  Client                                                Client
                    Client                                                Client
                     Client                                                Worker
                     Thread                                                Process
                                                    TCP/IP




3/3/2009                      http://ltsllc.com/slides/ipc.html                      38
Sockets vs Shared Memory
• Faster synchronization
     – 25 usec vs. 70 usec
• More bandwidth
     – 250 MB/sec vs. 15 MB/sec




3/3/2009           http://ltsllc.com/slides/ipc.html   39
Message Queues




3/3/2009      http://ltsllc.com/slides/ipc.html   40
Message Queues
•   Point to point
•   Message or stream
•   Client/Server
•   Synchronization support
•   No Java Support
•   No naming support


3/3/2009         http://ltsllc.com/slides/ipc.html   41
Message Queue Details
• Synchronization
     – Accept, read, write
     – 25 usec
• Bandwidth
     – 167 MB/sec




3/3/2009            http://ltsllc.com/slides/ipc.html   42
Platform Differences
• Direction
     – Linux is one-way
     – Windows is two-way
• Naming
     – Linux: any
     – Windows: must be .pipename
• Misc
     – Windows pipes are networkable
3/3/2009           http://ltsllc.com/slides/ipc.html   43
Message Queues: CLIP
•   MessageQueue class
•   One direction
•   File naming
•   JNI under the hood




3/3/2009         http://ltsllc.com/slides/ipc.html   44
Message Queues vs. Shared
                   Memory
• Less bandwidth
     – Synchronized: 250MB vs. 167MB
     – Unsynchronized: 1000MB vs. 167MB
• No Java support
• Platform differences




3/3/2009           http://ltsllc.com/slides/ipc.html   45
Semaphores




3/3/2009    http://ltsllc.com/slides/ipc.html   46
Semaphores
•   Synchronization only
•   Any to any
•   Access via increment/decrement
•   No Java support
•   No naming support




3/3/2009        http://ltsllc.com/slides/ipc.html   47
Semaphore Details
• Integer value
• Decrement reserves
     – Blocks if the value is 0 or less
• Increment releases
     – May wake a blocked process
• N-ary semaphores
     – Values other than 0 or 1


3/3/2009             http://ltsllc.com/slides/ipc.html   48
Semaphore Details
• Synchronization
     – 25 usec
• Platform naming differences
     – Linux: /somename
     – Windows: somename
     – Ad hoc access control



3/3/2009           http://ltsllc.com/slides/ipc.html   49
Semaphores CLIP
• Semaphore class
• File system naming
• JNI under the hood




3/3/2009      http://ltsllc.com/slides/ipc.html   50
Example: The Liminator




3/3/2009         http://ltsllc.com/slides/ipc.html   51
The Liminator: Requirements
• Start with Google Maps
• Too many processes == poor performance
• Limit processes with a semaphore
     – Initial value = max number of processes
     – Reserve when trying to spawn
     – Release when complete



3/3/2009           http://ltsllc.com/slides/ipc.html   52
Liminator: Design
                                    Semaphore




            Client                                              Client
             Client                                              Client
               Client                                              Client
                Client                                              Client
                  Client                                              Client
                   Client                                              Client



                                                                Running
           Waiting


3/3/2009                    http://ltsllc.com/slides/ipc.html                   53
Semaphores vs Shared Memory
• About the same speed
• No naming support
• No JRE support




3/3/2009      http://ltsllc.com/slides/ipc.html   54
Summary




3/3/2009   http://ltsllc.com/slides/ipc.html   55
Summary
• IPC
     – Multiple processes
     – Naming
     – Bandwidth
• CLIP
     – Open source Linux & Windows
     – New primitives via JNI
     – Simplify others

3/3/2009           http://ltsllc.com/slides/ipc.html   56
Summary of IPC Types
           IPC Type         Sync                  Band      Java
                                                          Support?



Semaphores                25 usec                   N/A     No

Sockets                   70 usec                 15MB      Yes

Message Queues            25 usec                167MB      No

Shared Memory             25 usec                250MB      Yes




3/3/2009              http://ltsllc.com/slides/ipc.html              57
Resources
Slides & code ltsllc.com/talks/ipc
Windows       msdn.microsoft.com
Linux          Advanced UNIX Programming
               basepath.com/aup/index.htm
Java           JTUX
               basepath.com/aup/jtux
Sun Forums     java.sun.com
Code Project   codeproject.com

3/3/2009         http://ltsllc.com/slides/ipc.html   58
The End




3/3/2009   http://ltsllc.com/slides/ipc.html   59
Which Option is Best?

                      No
                               Shared
           Sync?
                               Memory

              Yes


                    Yes                       Yes                    Yes
           Data?           > 10MB/s?                       1-to-1?


              No                   No                           No



                                                          Shared           Message
    Semaphores             Sockets
                                                         Memory*           Queues


3/3/2009                    http://ltsllc.com/slides/ipc.html                    60

Weitere ähnliche Inhalte

Ähnlich wie Java IPC and the CLIP library

Building a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesBuilding a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesMaxwell Dayvson Da Silva
 
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Jean-Philippe BEMPEL
 
DEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltrationDEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltrationFelipe Prado
 
Capture-HPC talk@ OSDC.tw 2009
Capture-HPC talk@ OSDC.tw 2009Capture-HPC talk@ OSDC.tw 2009
Capture-HPC talk@ OSDC.tw 2009Da-Chang Guan
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Clusterguestd34230
 
Getting Started with (Distributed) Version Control
Getting Started with (Distributed) Version ControlGetting Started with (Distributed) Version Control
Getting Started with (Distributed) Version ControlJohn Paulett
 
FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018Xavier Mertens
 
Rhonda Layfield Sniffing Your Network With Netmon 3.3
Rhonda Layfield   Sniffing Your Network With Netmon 3.3Rhonda Layfield   Sniffing Your Network With Netmon 3.3
Rhonda Layfield Sniffing Your Network With Netmon 3.3Nathan Winters
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharingJames Hsieh
 
Building a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesBuilding a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesFlávio Ribeiro
 
Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01Cahyo Darujati
 
WebRTC: A front-end perspective
WebRTC: A front-end perspectiveWebRTC: A front-end perspective
WebRTC: A front-end perspectiveshwetank
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAtlassian
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAtlassian
 
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-BayesOSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-BayesNETWAYS
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Varnish http accelerator
Varnish http acceleratorVarnish http accelerator
Varnish http acceleratorno no
 
Mcas log collector deck
Mcas log collector deckMcas log collector deck
Mcas log collector deckMatt Soseman
 

Ähnlich wie Java IPC and the CLIP library (20)

re7jweiss
re7jweissre7jweiss
re7jweiss
 
Building a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesBuilding a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York Times
 
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
Devoxx Fr 2022 - Remèdes aux oomkill, warm-ups, et lenteurs pour des conteneu...
 
DEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltrationDEFCON 23 - Etienne Martineau - inter vm data exfiltration
DEFCON 23 - Etienne Martineau - inter vm data exfiltration
 
Capture-HPC talk@ OSDC.tw 2009
Capture-HPC talk@ OSDC.tw 2009Capture-HPC talk@ OSDC.tw 2009
Capture-HPC talk@ OSDC.tw 2009
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Cluster
 
Getting Started with (Distributed) Version Control
Getting Started with (Distributed) Version ControlGetting Started with (Distributed) Version Control
Getting Started with (Distributed) Version Control
 
FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018
 
Rhonda Layfield Sniffing Your Network With Netmon 3.3
Rhonda Layfield   Sniffing Your Network With Netmon 3.3Rhonda Layfield   Sniffing Your Network With Netmon 3.3
Rhonda Layfield Sniffing Your Network With Netmon 3.3
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
Building a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York TimesBuilding a Video Encoding Pipeline at The New York Times
Building a Video Encoding Pipeline at The New York Times
 
Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01
 
WebRTC: A front-end perspective
WebRTC: A front-end perspectiveWebRTC: A front-end perspective
WebRTC: A front-end perspective
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA Hum
 
Administrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA HumAdministrivia: Golden Tips for Making JIRA Hum
Administrivia: Golden Tips for Making JIRA Hum
 
XS Boston 2008 Network Topology
XS Boston 2008 Network TopologyXS Boston 2008 Network Topology
XS Boston 2008 Network Topology
 
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-BayesOSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Varnish http accelerator
Varnish http acceleratorVarnish http accelerator
Varnish http accelerator
 
Mcas log collector deck
Mcas log collector deckMcas log collector deck
Mcas log collector deck
 

Kürzlich hochgeladen

QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 

Kürzlich hochgeladen (20)

QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 

Java IPC and the CLIP library

  • 1. Java IPC And the CLIP Library Clark N. Hobbie Long Term Software, LLC clark.hobbie@ltsllc.com
  • 2. Who Gives a Damn?
  • 3. You Should Care Because… • If you are in a corner • Java sync is one VM only • Others require JNI • Platform differences 3/3/2009 http://ltsllc.com/slides/ipc.html 3
  • 4. What Are the Options? • Sockets • Message Queues • Semaphores • Shared Memory 3/3/2009 http://ltsllc.com/slides/ipc.html 4
  • 5. Which Option Should I Use? Shared Memory • JRE support • Highest bandwidth • Decent synchronization • Naming support 3/3/2009 http://ltsllc.com/slides/ipc.html 5
  • 6. Why Should I Care about CLIP? • New primitives – Semaphores – Message Queues • Simplifies existing primitives – Shared Memory 3/3/2009 http://ltsllc.com/slides/ipc.html 6
  • 7. Java RandomAccessFile raf = new RandomAccessFile(quot;/temp/smfilequot;, quot;rwquot;); FileChannel chan = raf.getChannel(); MappedByteBuffer buf = chan.map(MapMode.READ_WRITE, 0, size); byte[] other = new byte[1024]; buf.position(0); buf.get(other, 0, 1024); 3/3/2009 http://ltsllc.com/slides/ipc.html 7
  • 8. CLIP SharedMemory smem = new SharedMemory(quot;/temp/smfilequot;); 3/3/2009 http://ltsllc.com/slides/ipc.html 8
  • 9. What is IPC? Inter-Process Communication (IPC) • Multiple processes • Naming • Synchronization • Bandwidth 3/3/2009 http://ltsllc.com/slides/ipc.html 9
  • 10. Naming Me Tarzan, who you? 3/3/2009 http://ltsllc.com/slides/ipc.html 10
  • 11. Naming How do you… • Connect processes together? • Determine who is allowed to connect? • Examples – TCP/IP? – Email? – Telephones? 3/3/2009 http://ltsllc.com/slides/ipc.html 11
  • 12. File Naming Many IPC methods use the file system because • Visible to all processes • Has access control built in 3/3/2009 http://ltsllc.com/slides/ipc.html 12
  • 13. File Naming Examples • Memory Mapped Files • Named Pipes/FIFOs 3/3/2009 http://ltsllc.com/slides/ipc.html 13
  • 14. Synchronization • Event ordering • Mutual exclusion 3/3/2009 http://ltsllc.com/slides/ipc.html 14
  • 15. Example: Online Purchase 1. Get user credit information 2. Decision purchase 3. Update credit information 3/3/2009 http://ltsllc.com/slides/ipc.html 15
  • 16. Without Event Ordering Client A Client B 1 Get credit info 2 Get credit info 2 Decision purchase 3 Update info 4 Decision purchase 5 Update info 3/3/2009 http://ltsllc.com/slides/ipc.html 16
  • 17. With Event Ordering Client A Client B 1 Get credit info 2 Wait for A 2 Decision purchase 3 Update info 4 Get credit info 5 Decision purchase 6 Update info 3/3/2009 http://ltsllc.com/slides/ipc.html 17
  • 18. Synchronization is Event Ordering Instead of this order: We want this order: • A gets credit info • A gets credit info • B gets credit info • A decisions purchase • A decisions purchase • A updates info • A updates info • B gets credit info • B decisions purchase • B decisions purchase • B updates credit info • B updates credit info 3/3/2009 http://ltsllc.com/slides/ipc.html 18
  • 19. Which Type of IPC is Appropriate? 3/3/2009 http://ltsllc.com/slides/ipc.html 19
  • 20. IPC Types • Shared Memory • Semaphores • Sockets • Message Queues 3/3/2009 http://ltsllc.com/slides/ipc.html 20
  • 21. Shared Memory 3/3/2009 http://ltsllc.com/slides/ipc.html 21
  • 22. Shared Memory • Preferred approach • Any to any • get/put semantics • Synchronization support • JRE support • Naming support 3/3/2009 http://ltsllc.com/slides/ipc.html 22
  • 23. Shared Memory Details • Synchronization – File Locking – Lock/unlock ~ 25 usec • Naming – File naming • Bandwidth – Synchronized 250MB/sec – Unsynchronized 1000MB/sec 3/3/2009 http://ltsllc.com/slides/ipc.html 23
  • 24. Memory Mapped Files • Start with a file – Appears the same to everyone – Reads/writes appear to everyone • Now speed it up – Until its as fast as memory – Like having the OS buffer 3/3/2009 http://ltsllc.com/slides/ipc.html 24
  • 25. Why Dear God, Why?!! • Originally Unix – Where everything is a file – mmap system call – CreateFileMapping system call • Solves the naming problem • Solves the access problem 3/3/2009 http://ltsllc.com/slides/ipc.html 25
  • 26. Example: World of Warcraft! Shared Memory! 3/3/2009 http://ltsllc.com/slides/ipc.html 26
  • 27. WoW: Requirements • One client process per player • One server process for all • Server periodically reads all orders • Server issues results 3/3/2009 http://ltsllc.com/slides/ipc.html 27
  • 28. WoW: Design Client Orders (EvilOne) Player Order EvilOne kill Client Lancelot kill (Lancelot) Client Martha Stewart kill (Conan) Conan make cookies … Client (Martha) 3/3/2009 http://ltsllc.com/slides/ipc.html 28
  • 29. WoW: Design Results Orders Server Process Player Result Player Order EvilOne dead EvilOne kill Lancelot Lancelot dead kill Martha Stewart Martha Stewart dead kill Conan overweight Conan make cookies … … 3/3/2009 http://ltsllc.com/slides/ipc.html 29
  • 30. Shared Memory: Summary • Preferred IPC • 250 to 1000MB/sec • File naming • Synchronization through file locking • JRE support 3/3/2009 http://ltsllc.com/slides/ipc.html 30
  • 31. Sockets 3/3/2009 http://ltsllc.com/slides/ipc.html 31
  • 32. Sockets • TCP/IP • Point to point • Stream oriented • Client/Server • Synchronized • Java support • Naming support 3/3/2009 http://ltsllc.com/slides/ipc.html 32
  • 33. Sockets Details • Naming – 127.0.0.1 port 7777 • Synchronization – Accept, read, write – 70 usec • Bandwidth – 15 MB/sec 3/3/2009 http://ltsllc.com/slides/ipc.html 33
  • 34. Sockets: CLIP • Some utility classes – ThreadedSocketServer • JRE already has excellent support 3/3/2009 http://ltsllc.com/slides/ipc.html 34
  • 35. Example: Google Maps Copyright © Google 3/3/2009 http://ltsllc.com/slides/ipc.html 35
  • 36. GMaps Combining Data Streets Image Overlay Images are Copyright © www.Google.com 3/3/2009 http://ltsllc.com/slides/ipc.html 36
  • 37. GMaps: Requirements • C legacy code • One instance/process • Receive file name • Process for 1 to 10 sec • Respond with new file name 3/3/2009 http://ltsllc.com/slides/ipc.html 37
  • 38. GMaps: Design Worker Pool Server Process Java VM Client Client Client Client Client Client Client Client Client Client Client Worker Thread Process TCP/IP 3/3/2009 http://ltsllc.com/slides/ipc.html 38
  • 39. Sockets vs Shared Memory • Faster synchronization – 25 usec vs. 70 usec • More bandwidth – 250 MB/sec vs. 15 MB/sec 3/3/2009 http://ltsllc.com/slides/ipc.html 39
  • 40. Message Queues 3/3/2009 http://ltsllc.com/slides/ipc.html 40
  • 41. Message Queues • Point to point • Message or stream • Client/Server • Synchronization support • No Java Support • No naming support 3/3/2009 http://ltsllc.com/slides/ipc.html 41
  • 42. Message Queue Details • Synchronization – Accept, read, write – 25 usec • Bandwidth – 167 MB/sec 3/3/2009 http://ltsllc.com/slides/ipc.html 42
  • 43. Platform Differences • Direction – Linux is one-way – Windows is two-way • Naming – Linux: any – Windows: must be .pipename • Misc – Windows pipes are networkable 3/3/2009 http://ltsllc.com/slides/ipc.html 43
  • 44. Message Queues: CLIP • MessageQueue class • One direction • File naming • JNI under the hood 3/3/2009 http://ltsllc.com/slides/ipc.html 44
  • 45. Message Queues vs. Shared Memory • Less bandwidth – Synchronized: 250MB vs. 167MB – Unsynchronized: 1000MB vs. 167MB • No Java support • Platform differences 3/3/2009 http://ltsllc.com/slides/ipc.html 45
  • 46. Semaphores 3/3/2009 http://ltsllc.com/slides/ipc.html 46
  • 47. Semaphores • Synchronization only • Any to any • Access via increment/decrement • No Java support • No naming support 3/3/2009 http://ltsllc.com/slides/ipc.html 47
  • 48. Semaphore Details • Integer value • Decrement reserves – Blocks if the value is 0 or less • Increment releases – May wake a blocked process • N-ary semaphores – Values other than 0 or 1 3/3/2009 http://ltsllc.com/slides/ipc.html 48
  • 49. Semaphore Details • Synchronization – 25 usec • Platform naming differences – Linux: /somename – Windows: somename – Ad hoc access control 3/3/2009 http://ltsllc.com/slides/ipc.html 49
  • 50. Semaphores CLIP • Semaphore class • File system naming • JNI under the hood 3/3/2009 http://ltsllc.com/slides/ipc.html 50
  • 51. Example: The Liminator 3/3/2009 http://ltsllc.com/slides/ipc.html 51
  • 52. The Liminator: Requirements • Start with Google Maps • Too many processes == poor performance • Limit processes with a semaphore – Initial value = max number of processes – Reserve when trying to spawn – Release when complete 3/3/2009 http://ltsllc.com/slides/ipc.html 52
  • 53. Liminator: Design Semaphore Client Client Client Client Client Client Client Client Client Client Client Client Running Waiting 3/3/2009 http://ltsllc.com/slides/ipc.html 53
  • 54. Semaphores vs Shared Memory • About the same speed • No naming support • No JRE support 3/3/2009 http://ltsllc.com/slides/ipc.html 54
  • 55. Summary 3/3/2009 http://ltsllc.com/slides/ipc.html 55
  • 56. Summary • IPC – Multiple processes – Naming – Bandwidth • CLIP – Open source Linux & Windows – New primitives via JNI – Simplify others 3/3/2009 http://ltsllc.com/slides/ipc.html 56
  • 57. Summary of IPC Types IPC Type Sync Band Java Support? Semaphores 25 usec N/A No Sockets 70 usec 15MB Yes Message Queues 25 usec 167MB No Shared Memory 25 usec 250MB Yes 3/3/2009 http://ltsllc.com/slides/ipc.html 57
  • 58. Resources Slides & code ltsllc.com/talks/ipc Windows msdn.microsoft.com Linux Advanced UNIX Programming basepath.com/aup/index.htm Java JTUX basepath.com/aup/jtux Sun Forums java.sun.com Code Project codeproject.com 3/3/2009 http://ltsllc.com/slides/ipc.html 58
  • 59. The End 3/3/2009 http://ltsllc.com/slides/ipc.html 59
  • 60. Which Option is Best? No Shared Sync? Memory Yes Yes Yes Yes Data? > 10MB/s? 1-to-1? No No No Shared Message Semaphores Sockets Memory* Queues 3/3/2009 http://ltsllc.com/slides/ipc.html 60