DEV Community

Sergiy Yevtushenko
Sergiy Yevtushenko

Posted on

2 1

The state of the Pragmatica (Feb 2022)

Since last publication, Pragmatica changed significantly. It started as a minimal set of classes necessary for Pragmatic Functional Java coding style, but over the last few months it grew into the fast asynchronous I/O core with support for network and file I/O (unlike, for example, Netty, which provides only network I/O).

What's new

The main change is that Pragmatica now supports representation of all special states:

  • Option<T> for missing values
  • Result<T> for "error or result" values
  • Promise<T> for "not yet available" values

Along with Promise<T> a whole new asynchronous I/O subsystem was implemented. It is based on modern asynchronous API which was recently added to the Linux kernel - io_uring. This enabled implementation of concurrency model which supports asynchronous operations for both, network and file I/O.

The implementation requires small number of threads (~1 thread per CPU core) and minimal synchronization overhead, which results in good throughput and scalability. Preliminary benchmarks show that this implementation has better throughput (up to 30% at high and very high load) than Netty.

The next change is that Pragmatica now consists of few modules:

  • Core, which contains base classes like Option<T>, Result<T>, etc.
  • Proactor, which contains low-level part, implemented as a Proactor pattern using Linux io_uring asynchronous API.
  • Async I/O - high level, Promise-based asynchronous API. It also contains (so far minimal) infrastructure for the implementation of various clients and servers (work in progress) as well as few file processing utilities (also WIP).
  • Examples (so far only one exists).

What's next

Below listed things which will be implemented next (roughly in order of priorities, from highest to lowest).

  • Support for remaining io_uring APIs. Among notable ones - sending/receiving of datagram (UDP) packets.
  • Run-time parameters configuration.
  • Significant parts of the library require testing.
  • Documentation and examples for existing code.
  • Asynchronous DNS API.
  • Support for SSL/TLS.
  • More file utilities.
  • Higher level protocols, most likely HTTP/1.1 will be first.

As one can see, there is still a lot of work ahead. So, if anyone wants to join and help - feel free to contact me here or at GitHub.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more