Skip to content

Releases: mroth/weightedrand

v2.1.0

13 Aug 17:20
Compare
Choose a tag to compare

What's Changed

As of go 1.21, global rand should no longer suffer from lock contention issues as long as rand.Seed (which was deprecated in go1.20) is not called. [reference] This removes the primary use case for Chooser.PickSource in this module, which was to avoid rand lock contention when using a single Choose in extremely high-throughput environments across multiple goroutines.

This update primarily updates documentation to reflect this, marking PickSource as deprecated in favor of just using the default Pick. The simple case will now perform just as well in that situation.

See #28 for details.

Full Changelog: v2.0.2...v2.1.0

v2.0.2

02 Aug 18:12
62d9872
Compare
Choose a tag to compare

What's Changed

  • Implement fuzz testing by @mroth in #27
  • fix: extreme edge case with ~uint64 weight >= platform maxInt, caught by fuzz testing 89fb685

Full Changelog: v2.0.1...v2.0.2

v2.0.1

02 Feb 02:06
Compare
Choose a tag to compare

What's Changed

  • Minor documentation cleanup reflecting convenience changes with global rand seeding in go1.20. In short, it will now happen by default, so probably no longer advisable to nag people about it in the README and examples.

Full Changelog: v2.0.0...v2.0.1

v2.0.0

14 Nov 20:59
0892404
Compare
Choose a tag to compare

🎉 weightedrand now utilizes generics for the container data structure to clean up the API and improve end-user ergonomics, thus typecasting is no longer required when obtaining your result, and can utilize any integer type for scores.

This requires a tiny code change if upgrading from a previous version (most likely just removing now unneeded typecasts), and manual upgrading of your import path to include the /v2 (see https://golang.cafe/blog/how-to-upgrade-to-a-major-version-in-go.html).

E.g. what used to be:

result := chooser.Pick().(type)

Can now simply be expressed as:

result := chooser.Pick()

This also means that the current version of the library requires go >= 1.18. For previous versions, you can continue to rely upon v1 of this library. The go module versioning system ensures you will not be automatically upgraded to a new major version without manual action.

What's Changed

  • v2: conversion to utilize go1.18 generics by @mroth in #14

Full Changelog: v1.0.0...v2.0.0

v1.0.0

14 Nov 20:03
Compare
Choose a tag to compare

What's Changed

Only CI and test related files, no changes to the library itself. This is a tagged v1.0.0 release to denote the finalization of this version of the API for API compatibility. This version will be preserved in the v1 branch.

A v2 release will closely follow integrating the API changes from generics in #14.

Full Changelog: v0.4.1...v1.0.0

v0.4.1

21 Dec 14:55
0d64275
Compare
Choose a tag to compare

Changelog

Contains a bug fix for a corner edge case introduced in #4. (thx @zifter!)

Fixed

  • Fix case with 1 choice which have weight equals 1 432cb4b

v0.4.0...v0.4.1

v0.4.0

30 Oct 00:24
953da99
Compare
Choose a tag to compare

Major Changes 🚧

This major release version changes the NewChooser constructor to check for and error on edge conditions that could later cause a runtime issue during Pick. NOTE: As this changes the API signature for NewChooser, thus you might have to adjust your code. Since we are still in pre-release semantic versioning now is the time to make these beneficial API refinements before we hit v1.0 and need to enforce stability.

// previous
func NewChooser(choices ...Choice) Chooser
// now
func NewChooser(choices ...Choice) (*Chooser, error)

All relevant documentation and examples has been updated to reflect this change.

Changelog

  • checked constructor for potential error conditions (#4) 953da99
  • docs: tiny word choice suggestion for clarity 3b00289

v0.3.1...v0.4.0

v0.3.1

09 Oct 16:08
Compare
Choose a tag to compare

Enhancements

The primary change in this release is an optimized internal implementation of the binary int search, replacing the Go standard library usage, resulting in a roughly ~33% further performance boost to samplings from a Chooser. 🐎

Changelog

  • docs: update benchmarks in README 4cbfa90
  • compbench: increase max items to 10 million 5a81164
  • bench: restore comparative benches as example pkg 31ddd19
  • docs: add code hint about future SIMD potential 12a8992
  • perf: manually inline SortSearchWrapper usage 29d84ac
  • ci: add go1.15 to test matrix f3b9ff9
  • ci: add dependabot config 0230c36
  • docs: simplify README example 8e20052
  • docs: update README badges 6130951
  • chore: change sample code b8555bc
  • docs: add codecov badge to README ceb1e77
  • ci: add code coverage workflow 09c370f
  • ci: enable race detector 48e5705

v0.3.0...v0.3.1

v0.3.0

21 Jul 21:17
Compare
Choose a tag to compare

New Features

🎲 The major new feature introduced in this version is the PickSource() method, which allows for utilizing a single Chooser in parallel across multiple goroutines while avoiding rand lock contention, thus allowing linearly scaling performance across CPU cores. For more details, see PR #2.

Changelog

  • docs: minor README updates 29716c5
  • Merge pull request #2 from mroth/rand-contention fcfd837
  • feat: parallel safe Pick to avoid rand contention 7a6357d
  • test: cleanup and modularize test file 6125a88
  • bench: add parallel perf test for lock contention 2526e09

v0.2.2...v0.3.0

v0.2.2

20 Jun 00:07
Compare
Choose a tag to compare

Changelog

Features:

  • NewChoice convenience constructor 6e178c3

Chores:

  • docs: add emoji to readme title 9bd1710
  • docs: add high-level example to godocs ea41bb4
  • chore: move example program into examples subdir d89c080
  • chore: remove files handled by default community health 73d3c1e
  • chore: rename test action f887590
  • ci: update action/setup-go to v2 88d7bfe
  • ci: update checkout action 81aa22d
  • ci: add go 1.14.x to test matrix 77de7f2

v0.2.1...v0.3.0