Skip to content

v0.16.0

Compare
Choose a tag to compare
@fwbrasil fwbrasil released this 13 Jan 20:22
· 1 commit to main since this release
9cdf197

Kyo 0.16.0

New Features

  • Scheduler integrations for Finagle and cats-effect: We've been observing positive results with kyo-scheduler-zio enabled for ZIO apps and this new version introduces integrations for both Finagle and cats-effect. For cats-effect, the integration enables replacing the default WorkStealingThreadPool with Kyo's high-performance work-stealing adaptive scheduler via KyoSchedulerIOApp or KyoSchedulerIORuntime. Admission control needs to be manually wired like in ZIO's integration. For Finagle, the integration uses extension points in Finagle's FinagleSchedulerService and ForkingScheduler, redirecting all FuturePool workload to Kyo's scheduler and automatically wiring the admission control in the server stack. The new module only needs to be in the classpath and Finagle locates it via service loading. These integrations should provide improved peak performance and scalability, especially in environments with CPU quotas due to the scheduler's CPU throttling mitigation via adaptive concurrency. These integration modules are isolated and don't include dependencies on the effect system.

  • Stream improvements and integrations: As mentioned in the last release, improving Streams is a key effort for Kyo 1.0. This release includes an integration with Reactive Streams and Java's Flow, the ability to stream values from a channel and from Hub listeners, new tap and tapChunk methods, and extensions to read and write gzip compressed data.

  • Batched Channel operations: Both reads and writes to channels now support batching, reducing the coordination overhead to exchange values between fibers. Additionally, the new drainUpTo method enables taking values immediately available in the channel without parking while properly considering pending puts.

  • Records: kyo-data, an isolated module without a dependency on the effect system, now offers an implementation of records based on intersection types to track available fields and types. The encoding enables type-level constraints, for example restricting what fields can be used in specific APIs, provides a proper sub-type relationship between records, automatic derivation from case classes, and convenient type-safe field access.

  • STM: TChunk, TSchedule, and TTable: The kyo-stm module now includes transactional versions of Chunk, Schedule, and a new record-based TTable, which offers a convenient API to store and query records with indexing support. The module also received some new optimizations.

  • Render type class: A new type class for rendering text representations of values was introduced in kyo-data and implementations for common Kyo types were introduced. This is an important aspect for usability given Kyo's extensive use of opaque types, which can lose fidelity when transformed via the regular toString.

  • Async.memoize and Async.never: Two new async combinators that respectively provide memoization of async computations and producing a computation that never completes.

  • Improved direct syntax: The direct syntax now provies extension methods .now and .later instead of await, which provides a more lightweight syntax. The .later extension is designed as an advanced API to enable composition of lazy effectful computations within defer blocks. In addition, the module was restructured to provide more informative compile-time error reporting.

  • Anchored and Jittered Schedules: The Schedule implementation in kyo-data now offers a Schedule.anchored constructor for cron-like schedules and a jitter method to introduce schedule duration variation. The STM module now uses a jittered retry schedule to reduce the impact of retry storms.

  • Emit and orDie combinators: The kyo-combinators module, which offers ZIO-like APIs, now includes extensions for the Emit effect and a new orDie combinator.

Improvements

  • IO now includes Abort[Nothing]: The IO effect now includes handling of unexpected panics via Abort[Nothing]. Computations that previously had IO & Abort[Nothing] in the pending set now can only include IO.

  • IOPromise improvements: IOPromise, the underlying implementation of Fiber, was fixed to ensure proper handling of non-fatal exceptions in callbacks and an optimization was implemented to avoid a nested AtomicReference allocation.

  • Async as a super set of IO: A new Async.apply method was introduced to provide side-effect suspension and enable using Async as a super set of IO in most scenarios. IO, the effect for side-effect suspension, and Async, the effect for handling asynchronous boundaries, had scaladocs improved to better explain the difference between these effects. For most users, using Async directly is recommended to reduce the effect tracking overhead.

  • KyoApp in JS: The implementation was fixed to avoid thread blocking so ScalaJS is properly supported.

  • New kyo-kernel module: The kernel of the library is now isolated from all effect implementations. Additionally, the module was restructured and its scaladoc documentation is improved.

  • Better exceptions: Exceptions for Kyo's APIs now extend a common KyoException base type, which provides better error reporting via Frame.

  • Chunk improvements: The implementation was optimized by extending StrictOptimizedSeqOps and providing more efficient iterator, take, appended methods. Additionally, more methods now return a Chunk instead of Seq for better usability and a bug in the implementation was fixed.

  • Scheduler improvements: Task preemption is now avoided in case the worker doesn't have other pending workload, parameters were tuned to provide a behavior similar to cats-effect's default scheduler, the distribution of the random number generation used for scheduling decisions was improved, and a mechanism was introduced to ensure Kyo's scheduler is a singleton even in the presence of multiple class loaders.

Breaking Changes

  • More clear method naming: The methods provided by Console now use more explicit naming by spelling Line instead of ln, atomic classes now provide compareAndSet instead of the shortened cas, Emit.apply was replaced by Emit.value, and Check.apply was replaced by Check.require.

  • Removed STM's initNow: The implementation in the STM module used to offer init and initNow to distinguish between transactional and non-transactional instantiation. This release removes all initNow methods and changes init to dynamically select transactional or non-transactional instantiation depending on the presence of an outer STM.run transaction.

  • Adopt With naming pattern: Methods that take a continuation function now use the With suffix. Most APIs now offer initWith and ContextEffect/Arrow.suspendAndMap are renamed to suspendWith.

Acknowledgements

  • A special thanks to @johnhungerford for the channel, stream, and combinator changes.
  • Congrats to @HollandDM on the first contributions, including an impressive integration with reactive streams!

Full Changelog: v0.15.1...v0.16.0