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

Improve performance, refactor NetexIdUtils #216

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

skjolber
Copy link
Contributor

@skjolber skjolber commented Jan 7, 2025

  • add lookup-table for char validation
  • add null check for validator
  • add more unit tests
  • add simple JMH benchmark
  • rewrite NetexIdUtils internals:
    • no more regexp
    • combine no.entur.abt.netex.id utils for the equivalent functionality

Benchmark results (higher is better - AMD 3700x)

Benchmark                                 Mode  Cnt    Score    Error   Units
IdBenchmark.codespaceNetexIdUtils        thrpt    5   50,077 ±  1,415  ops/us
IdBenchmark.codespaceNetexIdUtilsLegacy  thrpt    5    1,226 ±  0,085  ops/us
IdBenchmark.codespaceNonValidate         thrpt    5  198,865 ± 22,154  ops/us
IdBenchmark.codespaceTypePredicate       thrpt    5  142,560 ±  1,228  ops/us
IdBenchmark.codespaceValidate            thrpt    5   50,444 ±  0,280  ops/us
IdBenchmark.createFromNetexUtils         thrpt    5   14,214 ±  0,242  ops/us
IdBenchmark.createFromNetexUtilsLegacy   thrpt    5    0,575 ±  0,065  ops/us
IdBenchmark.createIdNetexUtils           thrpt    5   81,702 ±  0,624  ops/us
IdBenchmark.createIdNetexUtilsLegacy     thrpt    5   15,003 ±  5,916  ops/us
IdBenchmark.typeNetexIdUtils             thrpt    5   24,029 ±  0,918  ops/us
IdBenchmark.typeNetexIdUtilsLegacy       thrpt    5    1,265 ±  0,212  ops/us
IdBenchmark.typeNonValidate              thrpt    5  114,104 ±  0,970  ops/us
IdBenchmark.typeValidate                 thrpt    5   38,458 ±  0,709  ops/us
IdBenchmark.validate                     thrpt    5   72,461 ±  0,690  ops/us
IdBenchmark.validateNetexUtils           thrpt    5   72,488 ±  1,329  ops/us
IdBenchmark.validateNetexUtilsLegacy     thrpt    5    1,400 ±  0,187  ops/us
IdBenchmark.valueNetexIdUtils            thrpt    5   24,057 ±  1,226  ops/us
IdBenchmark.valueNetexIdUtilsLegacy      thrpt    5    1,246 ±  0,112  ops/us
IdBenchmark.valueNonValidate             thrpt    5  185,982 ±  9,244  ops/us
IdBenchmark.valueValidate                thrpt    5   24,214 ±  1,906  ops/us

The LegacyNetexIdUtils is a copy of the regexp-based (original) code, can be deleted.

@skjolber skjolber changed the title Add lookup-table type char validation for type and value Improve performance, refactor NetexIdUtils Jan 8, 2025
@skjolber
Copy link
Contributor Author

The LegacyNetexIdUtils is a copy of the regexp-based (original) code, can be deleted.

@skjolber
Copy link
Contributor Author

skjolber commented Jan 22, 2025

New AMD 9950 machine:

Standard JDK 21

Benchmark                                 Mode  Cnt    Score    Error   Units
IdBenchmark.codespaceNetexIdUtils        thrpt    5  126,429 ±  7,830  ops/us
IdBenchmark.codespaceNetexIdUtilsLegacy  thrpt    5    3,091 ±  0,975  ops/us
IdBenchmark.codespaceNonValidate         thrpt    5  555,455 ± 15,618  ops/us
IdBenchmark.codespaceTypePredicate       thrpt    5  337,825 ±  4,612  ops/us
IdBenchmark.codespaceValidate            thrpt    5  125,013 ±  3,434  ops/us
IdBenchmark.createFromNetexUtils         thrpt    5   43,496 ±  2,461  ops/us
IdBenchmark.createFromNetexUtilsLegacy   thrpt    5    1,603 ±  0,148  ops/us
IdBenchmark.createIdNetexUtils           thrpt    5  313,746 ± 18,643  ops/us
IdBenchmark.createIdNetexUtilsLegacy     thrpt    5   50,070 ±  2,603  ops/us
IdBenchmark.typeNetexIdUtils             thrpt    5   72,134 ±  5,240  ops/us
IdBenchmark.typeNetexIdUtilsLegacy       thrpt    5    3,109 ±  0,468  ops/us
IdBenchmark.typeNonValidate              thrpt    5  402,583 ± 37,437  ops/us
IdBenchmark.typeValidate                 thrpt    5  113,389 ±  5,360  ops/us
IdBenchmark.validate                     thrpt    5  193,013 ±  0,813  ops/us
IdBenchmark.validateNetexUtils           thrpt    5  193,559 ±  5,405  ops/us
IdBenchmark.validateNetexUtilsLegacy     thrpt    5    3,927 ±  0,419  ops/us
IdBenchmark.valueNetexIdUtils            thrpt    5   69,051 ±  1,356  ops/us
IdBenchmark.valueNetexIdUtilsLegacy      thrpt    5    3,162 ±  0,652  ops/us
IdBenchmark.valueNonValidate             thrpt    5  552,682 ± 14,101  ops/us
IdBenchmark.valueValidate                thrpt    5   69,663 ±  3,346  ops/us

GraalVM JDK 21 (not AOT compilation)

Benchmark                                 Mode  Cnt    Score    Error   Units
IdBenchmark.codespaceNetexIdUtils        thrpt    5  376,789 ± 20,741  ops/us
IdBenchmark.codespaceNetexIdUtilsLegacy  thrpt    5    4,408 ±  1,081  ops/us
IdBenchmark.codespaceNonValidate         thrpt    5  556,789 ±  5,422  ops/us
IdBenchmark.codespaceTypePredicate       thrpt    5  774,109 ±  3,644  ops/us
IdBenchmark.codespaceValidate            thrpt    5  374,470 ±  2,118  ops/us
IdBenchmark.createFromNetexUtils         thrpt    5  107,256 ±  3,434  ops/us
IdBenchmark.createFromNetexUtilsLegacy   thrpt    5    2,030 ±  0,414  ops/us
IdBenchmark.createIdNetexUtils           thrpt    5  302,459 ± 10,243  ops/us
IdBenchmark.createIdNetexUtilsLegacy     thrpt    5  363,848 ± 21,349  ops/us
IdBenchmark.typeNetexIdUtils             thrpt    5  370,131 ± 17,518  ops/us
IdBenchmark.typeNetexIdUtilsLegacy       thrpt    5    4,360 ±  1,517  ops/us
IdBenchmark.typeNonValidate              thrpt    5  476,044 ± 14,305  ops/us
IdBenchmark.typeValidate                 thrpt    5  369,747 ± 23,173  ops/us
IdBenchmark.validate                     thrpt    5  544,609 ± 31,397  ops/us
IdBenchmark.validateNetexUtils           thrpt    5  540,996 ± 15,232  ops/us
IdBenchmark.validateNetexUtilsLegacy     thrpt    5    5,522 ±  0,548  ops/us
IdBenchmark.valueNetexIdUtils            thrpt    5  377,084 ± 17,786  ops/us
IdBenchmark.valueNetexIdUtilsLegacy      thrpt    5    4,335 ±  0,990  ops/us
IdBenchmark.valueNonValidate             thrpt    5  552,430 ± 17,047  ops/us
IdBenchmark.valueValidate                thrpt    5  376,007 ± 20,083  ops/us

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.

1 participant