Skip to content

Conversation

@robin-aws
Copy link
Member

@robin-aws robin-aws commented Jun 17, 2025

What was changed?

Adds bulk operations to the Actions library - Producer.ForEach (renamed from ForEachRemaining), Producer.Fill, and BulkAction.Map - which can use type tests to optimize for common producers and consumers. This is particularly useful when using these traits to handle binary data, especially in streaming workflows, since it allows simple modelling of operations in terms of individual byte values, but does not force actually processing individual bytes at a time (which can introduce a lot of overhead, especially in languages like Java where the type system forces boxing values into Byte wrappers).

Also:

  • Added a twostate predicate ValidChange() to Validatable and several related helper predicates/lemmas/etc, since the specification of the bulk actions heavily relied on twostate invariants of actions such as old(history) <= history.
  • Added ActionsExterns.MakeSetReader<T>(s: set<T>), which creates a Producer<T> that reads the contents of a set in nondeterministic order in linear time. This is currently only implemented for Java and C#.
  • Modified the standard libraries example build process to also support target-specific examples (so the above can be exampled/tested for only Java and C#)
  • Made the --hidden-no-verify option recorded in doo files even though it is still normally unchecked, but added Makefile tests to ensure this is never used in checked-in doo files.

How has this been tested?

Added lots of additional examples. Note that the bulk operations are not really tested super well, especially in the use case of interacting with external producers and consumers, but a pending change to https://github.com/smithy-lang/smithy-dafny will have substantially more coverage by using these traits to support streaming for services such as S3.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

robin-aws added 18 commits June 16, 2025 14:10
…ing-libs

# Conflicts:
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-cs.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-go.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-java.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-js.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-notarget.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries-py.doo
#	Source/DafnyStandardLibraries/binaries/DafnyStandardLibraries.doo
@robin-aws robin-aws changed the title More streaming libs Add optimizable bulk operations to Actions, native and external SetReaders Jun 19, 2025
@robin-aws robin-aws marked this pull request as ready for review June 19, 2025 21:20
Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed everything, here is some general feedback and questions. Great addition !

Copy link
Member

@MikaelMayer MikaelMayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent job putting everything together. Thanks for the clarifications.

@robin-aws robin-aws merged commit 81dd553 into master Jun 24, 2025
22 checks passed
@robin-aws robin-aws deleted the more-streaming-libs branch June 24, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants