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

perf: improve performance of bytea string decoding #2320

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

bokken
Copy link
Member

@bokken bokken commented Oct 22, 2021

improve the parsing of bytea hex encoded string by making a lookup table
for each of the valid ascii code points to the 4 bit numeric value

This is inspired by #2232

The length in this jmh bench mark is length of the hex string, so resulting byte[] is half that length.
At small sizes, there is very little difference, but as the sizes get larger, the differences are substantial.

Benchmark             (length)  Mode  Cnt        Score        Error  Units
ByteaParser.parse           24  avgt    5       26.764 ±      0.424  ns/op
ByteaParser.parse          216  avgt    5      198.609 ±      1.070  ns/op
ByteaParser.parse         9872  avgt    5    36716.658 ±   1439.702  ns/op
ByteaParser.parse       198724  avgt    5  1075320.427 ± 123970.425  ns/op
ByteaParser.parseLUT        24  avgt    5       31.374 ±      2.441  ns/op
ByteaParser.parseLUT       216  avgt    5      179.361 ±      0.455  ns/op
ByteaParser.parseLUT      9872  avgt    5     8898.861 ±    117.963  ns/op
ByteaParser.parseLUT    198724  avgt    5   127577.077 ±   4428.223  ns/op

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Does ./gradlew autostyleCheck checkstyleAll pass ?
  3. Have you added your new test classes to an existing test suite in alphabetical order?

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

improve the parsing of bytea hex encoded string by making a lookup table
for each of the valid ascii code points to the 4 bit numeric value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant