Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow execution of large byte slice/string operations #2935

Open
notJoon opened this issue Oct 10, 2024 · 0 comments
Open

Slow execution of large byte slice/string operations #2935

notJoon opened this issue Oct 10, 2024 · 0 comments

Comments

@notJoon
Copy link
Member

notJoon commented Oct 10, 2024

Description

The stdlibs/bytes package tests are running slowly.

Tests like TestIndexByteNearPageBoundary, TestIndexNearPageBoundary, and TestCompareBytes take particularly long. These tests all use large byte slices.

Similar slow performance was seen in the p/demo/diff package tests when using strings.Repeat to create long strings.

=== RUN   TestMyersDiff/Worst-case_scenario_(completely_different_strings)
--- PASS: TestMyersDiff/Worst-case_scenario_(completely_different_strings) (29.70s)
=== RUN   TestMyersDiff/Very_long_strings
--- PASS: TestMyersDiff/Very_long_strings (23.81s)
--- PASS: TestMyersDiff (53.55s)
ok      examples/gno.land/p/demo/diff   54.24s

I suspect the VM is doing unnecessary work when generating and manipulating large strings or byte slices.

This problem was founded on PR #2616

bytes Execution Logs

=== RUN   TestEqualNearPageBoundary
--- PASS: TestEqualNearPageBoundary (0.07s)
=== RUN   TestIndexByteNearPageBoundary
--- PASS: TestIndexByteNearPageBoundary (12.94s)
=== RUN   TestIndexNearPageBoundary
--- PASS: TestIndexNearPageBoundary (12.73s)
=== RUN   TestNewBuffer
--- PASS: TestNewBuffer (0.00s)
=== RUN   TestNewBufferString
--- PASS: TestNewBufferString (0.00s)
=== RUN   TestBasicOperations
--- PASS: TestBasicOperations (0.00s)
=== RUN   TestLargeStringWrites
--- PASS: TestLargeStringWrites (0.03s)
=== RUN   TestLargeByteWrites
--- PASS: TestLargeByteWrites (0.04s)
=== RUN   TestLargeStringReads
--- PASS: TestLargeStringReads (0.01s)
=== RUN   TestLargeByteReads
--- PASS: TestLargeByteReads (0.01s)
=== RUN   TestMixedReadsAndWrites
--- PASS: TestMixedReadsAndWrites (0.09s)
=== RUN   TestCapWithPreallocatedSlice
--- PASS: TestCapWithPreallocatedSlice (0.00s)
=== RUN   TestCapWithSliceAndWrittenData
--- PASS: TestCapWithSliceAndWrittenData (0.00s)
=== RUN   TestNil
--- PASS: TestNil (0.00s)
=== RUN   TestReadFrom
--- PASS: TestReadFrom (0.03s)
=== RUN   TestReadFromPanicReader
--- PASS: TestReadFromPanicReader (0.00s)
=== RUN   TestReadFromNegativeReader
--- PASS: TestReadFromNegativeReader (0.00s)
=== RUN   TestWriteTo
--- PASS: TestWriteTo (0.02s)
=== RUN   TestRuneIO
--- PASS: TestRuneIO (0.14s)
=== RUN   TestWriteInvalidRune
--- PASS: TestWriteInvalidRune (0.00s)
=== RUN   TestNext
--- PASS: TestNext (0.00s)
=== RUN   TestReadBytes
--- PASS: TestReadBytes (0.00s)
=== RUN   TestReadString
--- PASS: TestReadString (0.00s)
=== RUN   TestGrow
--- PASS: TestGrow (16.31s)
=== RUN   TestGrowOverflow
--- PASS: TestGrowOverflow (0.00s)
=== RUN   TestReadEmptyAtEOF
--- PASS: TestReadEmptyAtEOF (0.00s)
=== RUN   TestUnreadByte
--- PASS: TestUnreadByte (0.00s)
=== RUN   TestBufferGrowth
--- PASS: TestBufferGrowth (1.55s)
=== RUN   TestEqual
--- PASS: TestEqual (0.00s)
=== RUN   TestEqualExhaustive
--- PASS: TestEqualExhaustive (0.30s)
=== RUN   TestNotEqual
--- PASS: TestNotEqual (1.64s)
=== RUN   TestIndex
--- PASS: TestIndex (0.05s)
=== RUN   TestLastIndex
--- PASS: TestLastIndex (0.04s)
=== RUN   TestIndexAny
--- PASS: TestIndexAny (0.00s)
=== RUN   TestLastIndexAny
--- PASS: TestLastIndexAny (0.00s)
=== RUN   TestLastIndexByte
--- PASS: TestLastIndexByte (0.00s)
=== RUN   TestIndexByteBig
--- PASS: TestIndexByteBig (5.21s)
=== RUN   TestIndexByteSmall
--- PASS: TestIndexByteSmall (4.75s)
=== RUN   TestIndexRune
--- PASS: TestIndexRune (0.10s)
=== RUN   TestCountByte
--- PASS: TestCountByte (84.63s)
=== RUN   TestCountByteNoMatch
--- PASS: TestCountByteNoMatch (14.10s)
=== RUN   TestSplit
--- PASS: TestSplit (0.00s)
=== RUN   TestSplitAfter
--- PASS: TestSplitAfter (0.00s)
=== RUN   TestFields
--- PASS: TestFields (0.00s)
=== RUN   TestFieldsFunc
--- PASS: TestFieldsFunc (0.00s)
=== RUN   TestMap
--- PASS: TestMap (0.00s)
=== RUN   TestToUpper
--- PASS: TestToUpper (0.00s)
=== RUN   TestToLower
--- PASS: TestToLower (0.00s)
=== RUN   TestToValidUTF8
--- PASS: TestToValidUTF8 (0.00s)
=== RUN   TestTrimSpace
--- PASS: TestTrimSpace (0.00s)
=== RUN   TestRepeat
--- PASS: TestRepeat (0.00s)
=== RUN   TestRepeatCatchesOverflow
--- PASS: TestRepeatCatchesOverflow (0.00s)
=== RUN   TestRunes
--- PASS: TestRunes (0.00s)
=== RUN   TestTrim
--- PASS: TestTrim (0.00s)
=== RUN   TestTrimFunc
--- PASS: TestTrimFunc (0.00s)
=== RUN   TestIndexFunc
--- PASS: TestIndexFunc (0.00s)
=== RUN   TestReplace
--- PASS: TestReplace (0.00s)
=== RUN   TestTitle
--- PASS: TestTitle (0.00s)
=== RUN   TestToTitle
--- PASS: TestToTitle (0.00s)
=== RUN   TestEqualFold
--- PASS: TestEqualFold (0.00s)
=== RUN   TestBufferGrowNegative
--- PASS: TestBufferGrowNegative (0.00s)
=== RUN   TestBufferTruncateNegative
--- PASS: TestBufferTruncateNegative (0.00s)
=== RUN   TestBufferTruncateOutOfRange
--- PASS: TestBufferTruncateOutOfRange (0.00s)
=== RUN   TestContains
--- PASS: TestContains (0.00s)
=== RUN   TestContainsAny
--- PASS: TestContainsAny (0.00s)
=== RUN   TestContainsRune
--- PASS: TestContainsRune (0.00s)
=== RUN   TestCompare
--- PASS: TestCompare (0.03s)
=== RUN   TestCompareIdenticalSlice
--- PASS: TestCompareIdenticalSlice (0.00s)
=== RUN   TestCompareBytes
--- PASS: TestCompareBytes (185.59s)
=== RUN   TestEndianBaseCompare
--- PASS: TestEndianBaseCompare (1.17s)
=== RUN   TestReader
--- PASS: TestReader (0.00s)
=== RUN   TestReadAfterBigSeek
--- PASS: TestReadAfterBigSeek (0.00s)
=== RUN   TestReaderAt
--- PASS: TestReaderAt (0.00s)
=== RUN   TestReaderWriteTo
--- PASS: TestReaderWriteTo (0.00s)
=== RUN   TestReaderLen
--- PASS: TestReaderLen (0.00s)
=== RUN   TestUnreadRuneError
--- PASS: TestUnreadRuneError (0.00s)
=== RUN   TestReaderDoubleUnreadRune
--- PASS: TestReaderDoubleUnreadRune (0.00s)
=== RUN   TestReaderCopyNothing
--- PASS: TestReaderCopyNothing (0.00s)
=== RUN   TestReaderLenSize
--- PASS: TestReaderLenSize (0.00s)
=== RUN   TestReaderReset
--- PASS: TestReaderReset (0.00s)
=== RUN   TestReaderZero
--- PASS: TestReaderZero (0.00s)
ok      gnovm/stdlibs/bytes     517.89s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

1 participant