Skip to content

Propagate warnings when calling .length on Vector#14744

Merged
JaroslavTulach merged 25 commits intodevelopfrom
wip/jtulach/WarningVectorLength11570
Mar 30, 2026
Merged

Propagate warnings when calling .length on Vector#14744
JaroslavTulach merged 25 commits intodevelopfrom
wip/jtulach/WarningVectorLength11570

Conversation

@JaroslavTulach
Copy link
Copy Markdown
Member

@JaroslavTulach JaroslavTulach commented Feb 10, 2026

Pull Request Description

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

@JaroslavTulach JaroslavTulach self-assigned this Feb 10, 2026
@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Feb 10, 2026
@JaroslavTulach JaroslavTulach requested a review from 4e6 as a code owner February 10, 2026 07:08
@JaroslavTulach JaroslavTulach added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Feb 10, 2026
@JaroslavTulach
Copy link
Copy Markdown
Member Author

There seems to be one test failure:

Use a slice of an array as vectors 114✅ 1❌
❌ Warnings and each
Expected False to be True (at /runner/_work/enso/enso/test/Base_Tests/src/Data/Vector_Spec.enso:1053:17-36).

Failure in JVM tests seems to be caused by outdated caches - e.g. not clean build

@JaroslavTulach
Copy link
Copy Markdown
Member Author

Use a slice of an array as vectors 114✅ 1❌
❌ Warnings and each
Expected False to be True (at /runner/_work/enso/enso/test/Base_Tests/src/Data/Vector_Spec.enso:1053:17-36).

  • I had to disable the check in 9383295
  • the Array elements are unlikely to have warning attached
    • the warning is assigned to the whole Array
    • but elements are without warnings
  • not sure why it worked before...

@JaroslavTulach
Copy link
Copy Markdown
Member Author

  • another failure related to each
  • VectorTest.insertSelfWithWarningViaForEach

@JaroslavTulach
Copy link
Copy Markdown
Member Author

Use a slice of an array as vectors 114✅ 1❌
❌ Warnings and each
Expected False to be True (at /runner/_work/enso/enso/test/Base_Tests/src/Data/Vector_Spec.enso:1053:17-36).

* I had to disable the check in [9383295](https://github.com/enso-org/enso/commit/93832952b6cc260838bf67ee5e0c22b4b9cdefb1)

* the `Array` elements are unlikely to have warning attached
  
  * the warning is assigned to the whole `Array`
  * but elements are without warnings

* not sure why it worked before...
  • there is still a failing test VectorTest.insertSelfWithWarningViaForEach
  • the problem is Array_Like_Helpers.each implementation and its treatment of warnings
  • the implementation calls vector.length and then uses it to iterate over 0.up_to len
    • in the new version that strips the warnings
    • and then reattached them later to the whole result
    • making elements passed to each callback warning less
  • calling the old version of length (that doesn't touch warnings) in Array_Like_Helpers.each seems to "fix" the problem

@JaroslavTulach
Copy link
Copy Markdown
Member Author

The problem with currently failing VectorTest is that InsertBuiltinVectorNode now produces WithWarnings[Vector.Generic] because length is associated with a warning!

obrazek

@JaroslavTulach
Copy link
Copy Markdown
Member Author

  • re-running failed jobs to find out how greenish this PR really is

@JaroslavTulach
Copy link
Copy Markdown
Member Author

JaroslavTulach commented Mar 26, 2026

  • we seem to have a failure in Table_Tests when running
  • sbt 'runEngineDistribution --run test/Table_Tests should.allow.basic.operations'
  • after bisecting the failure seems to be caused by f476f85
  • now it feels like catch 22:
    • sometimes (arr.each for example) we don't want to remove warnings from the elements)
    • sometimes (when calling to Java) we want to remove the warnings from the elements
  • live would be so much easier, if we had Use asHostObject and simplify handling of WithWarnings #14833
    • we could keep the warnings with elements
    • they would be removed by asHostObject call when needed
  • backing f476f85 out and running test/Base_Tests works!?

Let's try to back f476f85 out!

results_multiple.if_not_error (results_multiple.at 0)
res = results_multiple.if_not_error (results_multiple.at 0)
if propagate_warnings then res else
Warning.remove_warnings res
Copy link
Copy Markdown
Member Author

@JaroslavTulach JaroslavTulach Mar 26, 2026

Choose a reason for hiding this comment

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

  • there is a lot of changes in this PR some kept, some backed out
  • with the assumption of the PR becoming greenish soon, here is my retrospective
  • the key fixed in this PR are:

Differentiate between length and raw_size

Warning.remove_warning was Broken

  • it didn't work at all for Vector and Array
  • e.g. for anything else than WithWarnings wrapper
  • this got fixed in 1924195

Explicitly Removing Warnings

  • once the previous problem got fixed and removing warnings is reliable
  • it is now possible to explicitly remove warnings when propagate_warnings.not
  • done 58802e4
  • doing the removal explicitly at the right place seems to be the core of obtaining consistency

Intricate Construction of ArrayList

  • 4cd21cb introduces a way to construct Array with elements with warnings
  • that provides consistent behavior of various Vector types in Vector_Spec
  • bringing more clarity into the test suite

@JaroslavTulach
Copy link
Copy Markdown
Member Author

JaroslavTulach commented Mar 26, 2026

Benchmarking Engine

it is slow worst regression

@JaroslavTulach
Copy link
Copy Markdown
Member Author

JaroslavTulach commented Mar 26, 2026

Benchmarking StdLib

var add =
Stream.of(
"--foe=true",
"-jvmArgsAppend=--add-opens=org.graalvm.polyglot/org.graalvm.polyglot=ALL-UNNAMED");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

With this change, it is possible to run a benchmark and easily polyglot profile it:

sbt:runtime-benchmarks> benchOnly VectorBenchmarks.averageOverArray

and meanwhile in VisualVM:

BenchOnlyWithPolyglotSampler


@Specialization
long doLong(long l) {
return l;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The VectorBenchmarks were slow because of expensive check for isNull:

isNullCheck

Avoiding the check in a623bb3 for typical Enso values.

@JaroslavTulach
Copy link
Copy Markdown
Member Author

JaroslavTulach commented Mar 30, 2026

Benchmarking StdLib

I see some improvements:

improvement1 improvement2 improvement3

Overall the standard library results are OKeyish.

@JaroslavTulach JaroslavTulach merged commit de9f00f into develop Mar 30, 2026
77 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/WarningVectorLength11570 branch March 30, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vector.length doesn't propagate vector Warning with the length value

3 participants