summaryrefslogtreecommitdiff
path: root/libs/androidfw/tests/CursorWindow_test.cpp
AgeCommit message (Collapse)Author
2020-10-20Fixed CursorWindow signed math for x86 builds.Jeff Sharkey
All tests for our recent CursorWindow changes have been passing for ARM 64-bit builds, but they weren't executed against 32-bit x86 builds until after merged. It's not actually safe to use the "off_t" type, so we need to cast to "int32_t" when doing checks against possible-negative values, such as in allocRow(). We also add tests that verify negative rows/columns are identified as invalid positions, which requires that we check the resulting pointer against both mSlotsEnd and mSlotsStart. Bug: 169251528, 171276404, 171275409 Test: atest libandroidfw_tests:CursorWindowTest Test: atest CtsDatabaseTestCases Change-Id: Iea5f7546850f691e183fbb6e6d0952cd02b00d0f
2020-10-19Rewrite of CursorWindow internals.Jeff Sharkey
The original CursorWindow implementation was created in Android 1.0 and has remained relatively unchanged since then. Unfortunately that design results in very poor performance on large windows, since reading or writing each FieldSlot is O(row/100) to traverse through a chain of RowSlotChunks. It's also memory-inefficient due to how it allocates RowSlotChunks in 404 byte chunks, even when there's only a single row to store. This change is a complete redesign of the CursorWindow internals to use a "heap-and-stack" style approach, where a "heap" of strings and blobs increment up from the bottom of the window while a "stack" of FieldSlots increment down from the top of the window. The included benchmarks show the following improvements, ensuring no regressions for small windows, while offering very dramatic improvements for larger windows: Big cores Little cores 4x4 cursor no regression no regression 1024x4 cursor 2.2x faster 2.0x faster 16384x4 cursor 48.5x faster 24.4x faster Detailed unit testing is also included to ensure that the rewrite behaves correctly. Bug: 169251528 Test: atest libandroidfw_tests Test: atest CtsDatabaseTestCases Test: atest FrameworksCoreTests:android.database Test: ./frameworks/base/libs/hwui/tests/scripts/prep_generic.sh little && atest libandroidfw_benchmarks Test: ./frameworks/base/libs/hwui/tests/scripts/prep_generic.sh little && atest CorePerfTests:android.database.CrossProcessCursorPerfTest Change-Id: I90dff31fd550130dae917a33e0e1fa684e15c107