project-loom | A short and practical intro into project loom | Runtime Evironment library

 by   ashwinbhaskar Java Version: Current License: No License

kandi X-RAY | project-loom Summary

kandi X-RAY | project-loom Summary

project-loom is a Java library typically used in Server, Runtime Evironment applications. project-loom has no bugs, it has no vulnerabilities and it has low support. However project-loom build file is not available. You can download it from GitHub.

Project loom is all about making concurrency easier (for developers) on the JVM. It is in experimental phase. Download the early access builds here.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              project-loom has a low active ecosystem.
              It has 16 star(s) with 0 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              project-loom has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of project-loom is current.

            kandi-Quality Quality

              project-loom has 0 bugs and 0 code smells.

            kandi-Security Security

              project-loom has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              project-loom code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              project-loom does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              project-loom releases are not available. You will need to build from source code and install.
              project-loom has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              It has 59 lines of code, 4 functions and 2 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed project-loom and discovered the below as its top functions. This is intended to give you an instant insight into project-loom implemented functionality, and help decide if they suit your requirements.
            • Main entry point
            • Example of how to write out threads
            Get all kandi verified functions for this library.

            project-loom Key Features

            No Key Features are available at this moment for project-loom.

            project-loom Examples and Code Snippets

            No Code Snippets are available at this moment for project-loom.

            Community Discussions

            QUESTION

            Project loom, what happens when virtual thread makes a blocking system call?
            Asked 2021-Nov-30 at 21:58

            I was investigating how Project Loom works and what kind of benefits it can bring to my company.

            So I understand the motivation, for standard servlet based backend, there is always a thread pool that executes a business logic, once thread is blocked because of IO it can't do anything but wait. So let's say I have a backend application that has single endpoint , the business logic behind this endpoint is to read some data using JDBC which internally uses InputStream which again will use blocking system call( read() in terms of Linux). So if I have 200 hundred users reaching this endpoint, I need to create 200 threads each waiting for IO.

            Now let's say I switched a thread pool to use virtual threads instead. According to Ben Evans in the article Going inside Java’s Project Loom and virtual threads:

            Instead, virtual threads automatically give up (or yield) their carrier thread when a blocking call (such as I/O) is made.

            So as far as I understand, if I have amount of OS threads equals to amount of CPU cores and unbounded amount of virtual threads, all OS threads will still wait for IO and Executor service won't be able to assign new work for Virtual threads because there are no available threads to execute it. How is it different from regular threads , at least for OS threads I can scale it to thousand to increase the throughput. Or Did I just misunderstood the use case for Loom ? Thanks in advance

            Addon

            I just read this mailing list:

            Virtual threads love blocking I/O. If the thread needs to block in say a Socket read then this releases the underlying kernel thread to do other work

            I am not sure I understand it, there is no way for OS to release the thread if it does a blocking call such as read, for these purposes kernel has non blocking syscalls such as epoll which doesn't block the thread and immediately returns a list of file descriptors that have some data available. Does the quote above implies that under the hood , JVM will replace a blocking read with non blocking epoll if thread that called it is virtual ?

            ...

            ANSWER

            Answered 2021-Nov-30 at 21:58

            Your first excerpt is missing the important point:

            Instead, virtual threads automatically give up (or yield) their carrier thread when a blocking call (such as I/O) is made. This is handled by the library and runtime [...]

            The implication is this: if your code makes a blocking call into the library (for example NIO) the library detects that you call it from a virtual thread and will turn the blocking call into a non-blocking call, park the virtual thread and continue processing some other virtual threads code.

            Only if no virtual thread is ready to execute will a native thread be parked.

            Note that your code never calls a blocking syscall, it calls into the java libraries (that currently execute the blocking syscall). Project Loom replaces the layers between your code and the blocking syscall and can therefore do anything it wants - as long as the result for your calling code looks the same.

            Source https://stackoverflow.com/questions/70174468

            QUESTION

            What logical flow model is used for event loop in Nodejs (Google Chrome)
            Asked 2021-Jun-29 at 19:28

            For a long time I thought that event loop implementation (libuv?) used in Chrome and Node.js used threads. But then I was reading this article on lightweight threads in Java that stated the following:

            ...instead of creating threads for each concurrent task (and blocking tasks), a dedicated thread (called an event loop) looks through all the tasks that are assigned to threads in a non-reactive model, and processes each of them on the same CPU core.

            And the the book Computer Systems. A Programmer’s Perspective in the chapter on concurrent applications states that modern operating systems provide three basic approaches for building concurrent programs (3 approaches to implementing logic flows):

            • Processes. With this approach, each logical control flow is a process that is scheduled and maintained by the kernel. Since processes have separate virtual address spaces, flows that want to communicate with each other must use some kind of explicit interprocess communication (IPC) mechanism.

            • I/O multiplexing. This is a form of concurrent programming where applications explicitly schedule their own logical flows in the context of a single process. Logical flows are modeled as state machines that the main program explicitly transitions from state to state as a result of data arriving on file descriptors. Since the program is a single process, all flows share the same address space.

            • Threads. Threads are logical flows that run in the context of a single process and are scheduled by the kernel. You can think of threads as a hybrid of the other two approaches, scheduled by the kernel like process flows and sharing the same virtual address space like I/O multiplexing flows.

            So now I'm wondering now if the event loop falls under I/O multiplexing logical flow and doesn't use threads?

            ...

            ANSWER

            Answered 2021-Jun-29 at 19:28

            I have nothing to do with V8 team, but I'll try to answer the question.

            First of all, V8 itself has nothing to do with an event loop. Node.js uses libuv to implement the event loop plus abstractions for OS-specific APIs (network, FS, and so on). The event loop itself is run on a single OS thread and most of the network operations are executed on that thread based I/O multiplexing APIs (epoll, kqueue, etc.).

            But libuv also has a thread pool to run blocking I/O (e.g. FS, DNS lookups) and CPU intensive operations (e.g. crypto). The thread pool is integrated (communicates) with the event loop through an in-memory queue. When a blocking/CPU intensive task has to be started it's put into the queue and later on one of the threads starts processing it.

            So, Node.js uses a number of approaches to achieve concurrency among the user operations: OS threads (BTW this includes the worker_threads module), I/O multiplexing, multiple processes (with the child_process module).

            V8 also uses a number of OS threads for its own purposes (say, GC), but it doesn't need to be aware of the event loop or provide any abstractions for the OS-level APIs. Its goal is to, well, execute the given JS code and provide a solid embedder API, so that you can build a browser/runtime with it.

            Source https://stackoverflow.com/questions/68176293

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install project-loom

            You can download it from GitHub.
            You can use project-loom like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the project-loom component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/ashwinbhaskar/project-loom.git

          • CLI

            gh repo clone ashwinbhaskar/project-loom

          • sshUrl

            git@github.com:ashwinbhaskar/project-loom.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link