-
Notifications
You must be signed in to change notification settings - Fork 36
Add fastPfor decoder to Typescript #714
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
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 23e531c.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #714 +/- ##
==========================================
+ Coverage 83.35% 83.80% +0.44%
==========================================
Files 57 58 +1
Lines 2439 2605 +166
Branches 554 588 +34
==========================================
+ Hits 2033 2183 +150
- Misses 380 394 +14
- Partials 26 28 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mactrem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good first draft!
Let's add benchmarks via Benchmark.js to compare the decoding performance with varint encoding based on different datasets
| import IntWrapper from "./intWrapper"; | ||
|
|
||
| // encoded data was generated using the java fastPfor encoder and expected values are re-generated in the tests | ||
| const ENCODED_NON_ALINGED_358_ENCODED = new Uint8Array([0, 0, 1, 0, 0, 0, 0, 65, 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20, 27, 26, 25, 24, 31, 30, 29, 28, 35, 34, 33, 32, 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44, 51, 50, 49, 48, 55, 54, 53, 52, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the FastPfor test data as binary files to keep the tests more clean.
Also let's add more test cases to ensure that the implementation is also valid for edge cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i switched to using binary files and will add more tests
| const hasTrailingBytes = byteLength % 4 !== 0; | ||
| const numInts = hasTrailingBytes ? numCompleteInts + 1 : numCompleteInts; | ||
|
|
||
| const intValues = new Int32Array(numInts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are two copies generated (data. slice and intValues) before decoding the actual data. Let's reduce the number of data transformations, because at least we do not need slice. Additionaly, if the offset into the data buffer is aligned (to 4 bytes) no copy is needd at all. One approach to complety avoid the copies is to directly work on the DataView but which leads to a slower data access performance see https://v8.dev/blog/dataview. But first let's add benchmarks (against varint as baseline) and then let's optimize
|
I will start benchmarking the decoder with different tilesets i encoded accordingly. But i'm not sure if we want to have those benchmarks in the repo itself. |
We can think about publishing a seperate package for the fastpfor decoder |
This PR introduces fastPfor decoding to typesctipt