Skip to content

Conversation

@JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Nov 18, 2025

Pull Request Description

Checklist

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

  • All code follows the
    Scala,
    Java,
  • Unit tests have been written where possible.
  • Are library benchmarks influenced by Buffer usage?

@JaroslavTulach JaroslavTulach self-assigned this Nov 18, 2025
@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Nov 18, 2025
@JaroslavTulach JaroslavTulach marked this pull request as draft November 18, 2025 10:40
@JaroslavTulach
Copy link
Member Author

  • With 6655b7b the computation of Mean is as fast in dual JVM mode as in single JVM
Mean is fast - we have the solution, @jdunkerley - now there is time to design the system properly! - data were captured with following command
sbt:enso> runEngineDistribution 
  --vm.D=polyglot.enso.classLoading=Standard.Generic_JDBC:guest,hosted 
  --run /home/devel/enso-projects/SQLite/03-GenericConnect 
  --profiling-path /tmp/better.npss

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Nov 20, 2025

There are performance regressions when running stdlib benchmarks. For example:

[org_enso_benchmarks_generated_Column_Arithmetic_1000000_Plus_Nothing](file:///run/user/1000/doc/370b903e/stdlib-benchs.html#org_enso_benchmarks_generated_Column_Arithmetic_1000000_Plus_Nothing)

use

sbt:enso> std-benchmarks/benchOnly Column_Arithmetic_1000000.Plus_Nothing

to run such a benchmark. Should be faster with b084696 - update on Nov 21: Yes, the enormous regression is gone, but still we have 2-3x slowdown mostly in Column_Arithmetic_1000000 benchmarks:

image

Slowdown is very likely coming from LongIterator.bgv. Time to speed it up!

@JaroslavTulach JaroslavTulach changed the title LongStorage over ByteBuffer LongStorage & co. over ByteBuffer to allow dual JVM buffer exchange Nov 21, 2025
@JaroslavTulach JaroslavTulach changed the title LongStorage & co. over ByteBuffer to allow dual JVM buffer exchange Arrow like storage over ByteBuffer to allow dual JVM buffer exchange Nov 21, 2025
@JaroslavTulach
Copy link
Member Author

Slowdown is very likely coming from LongIterator.bgv. Time to speed it up!

compare

The graph on left is the new LongBuffer.wrap version. The graph on right is the current long[] version. As can be seen, the LongBuffer is doing more operations as the code is more generic. It needs to check limit, it has concept of offset. It always reads hb array again (not sure why, that doesn't seem necessary to me). In any case, with these additional operations we just have to expect some slowdown.

@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/AverageOverByteBuffer13851 branch from 33f6403 to 727631e Compare November 25, 2025 08:13
mergify bot pushed a commit that referenced this pull request Nov 26, 2025
…river (#14357)

- _dual JVM_ benchmark to track progress of #13851
- `Column` is loaded by `Standard.Generic_JDBC` module, but the mean is computed by `Standard.Table`
- that (in _dual JVM mode_) means the `Column` data are **crossing the boundary**

# Important Notes
- with c35aa2e we can run both tests at the same time:
```
sbt:enso> std-benchmarks/benchOnly JDBC.mean
[info] Benchmark                     Mode  Cnt    Score   Error  Units
[info] Dual_JVM_Generic_JDBC.mean    avgt       544,708          ms/op
[info] Single_JVM_Generic_JDBC.mean  avgt        32,655          ms/op
```
- e.g. **20x** slower for now
- #14309 will make it faster
@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/AverageOverByteBuffer13851 branch from 6464402 to 4a052e8 Compare November 27, 2025 15:21
*/
default long rawCapacity() {
return getSize();
}
Copy link
Member Author

@JaroslavTulach JaroslavTulach Nov 27, 2025

Choose a reason for hiding this comment

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

Works Fast!

sbt:std-benchmarks> benchOnly mean
[info] Benchmark                     Mode  Cnt   Score   Error  Units
[info] Dual_JVM_Generic_JDBC.mean    avgt       33,393          ms/op
[info] Single_JVM_Generic_JDBC.mean  avgt       36,639          ms/op

Appendix: A Vision that Failed

  • in one of the previous prototypes there was rawAddress and rawValidityAddress
    • in the process of rewriting the goal shifted to unify these two into one rawAddress and getSize()
    • however then it turned out that getSize() can be different than capacity of the buffer
  • hence we are back to two values rawAddress, rawCapacity and also getSize()
  • it might have been simpler to stick with the two rawAddressandrawValidityAddress` addresses...

}

@Test
public void testCreateViaBuilderAndReadViaArrow() {
Copy link
Member Author

@JaroslavTulach JaroslavTulach Nov 27, 2025

Choose a reason for hiding this comment

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

Tested for Compatibility with Arrow (and Arrow Language)

  • ca62140 generates LongStorage by LongBuilder
  • and reads it via ArrowLanguage expecting the same result
  • not only that guarantees our format is Arrow compatible
  • but it also ensures that whatever formats are generated by our storage Java code
  • are also supported by ArrowLanguage
  • e.g. we have all the pieces we need to drop the Java code and use ArrowLanguage when the time comes

Copy link
Member Author

Choose a reason for hiding this comment

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

  • Basic compatibility achieved at 89955a0
  • more work remaining as aad18a7 demonstrates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Use Arrow format for IntegerColumn, exchange between JVMs and Python

3 participants