Skip to content

Improve parsers efficiency #222

Open
Open
@phenpessoa

Description

@phenpessoa

TLDR

(Original TLDR at the end of this comment)

While I was working on removing regexes from parsers, I noticed that the speed gain and reduced usage was not as much as I expected it to be. So I decided to rework the parsers completely, instead of just removing regexes.

For more complex parsers, such as the character one, I'm gonna start by removing the regexes and later try to rewrite it completely. As this is a far more complex task and removing the regexes is already a huge performance boost for such parsers.

But for boostable bosses, for example, while removing regexes gave a 50% speed boost and reduced allocations by 4% rewriting the parser was relatively simple and gave a 98% speed boost while reducing allocations by almost 100%

Files to remove regex from or rewrite parsers:

TibiaBoostableBossesOverview

TibiaCharactersCharacter

TibiaCreaturesCreature

  • CreatureDataRegex
  • CreatureHitpointsRegex
  • CreatureImmuneRegex
  • CreatureStrongRegex
  • CreatureWeakRegex
  • CreatureHealedRegex
  • CreatureManaRequiredRegex
  • CreatureLootRegex

TibiaCreaturesOverview

  • BoostedCreatureNameAndRaceRegex
  • BoostedCreatureImageRegex
  • CreatureInformationRegex

TibiaDataUtils

TibiaFansites

  • FansiteInformationRegex
  • FansiteImgTagRegex
  • FansiteLanguagesRegex
  • FansiteAnchorRegex

TibiaGuildsGuild

  • GuildLogoRegex
  • GuildWorldAndFoundationRegex
  • GuildHomepageRegex
  • GuildhallRegex
  • GuildDisbaneRegex
  • GuildMemberInformationRegex
  • GuildMemberInvitesInformationRegex

TibiaHighscores

  • HighscoresAgeRegex
  • HighscoresPageRegex
  • SevenColumnRegex
  • SixColumnRegex

TibiaHousesHouse

  • houseDataRegex
  • housePassingRegex
  • moveOutRegex
  • paidUntilRegex
  • houseAuctionedRegex

TibiaHousesOverview

  • houseOverviewDataRegex
  • houseOverviewAuctionedRegex

TibiaNews

  • martelRegex

TibiaSpellsSpell

  • SpellDataRowRegex
  • SpellNameAndImageRegex
  • SpellCooldownRegex
  • SpellDescriptionRegex

TibiaWorldsOverview

  • worldPlayerRecordRegex
  • worldInformationRegex
  • worldBattlEyeProtectedSinceRegex

TibiaWorldsWorld

  • WorldDataRowRegex
  • WorldRecordInformationRegex
  • BattlEyeProtectedSinceRegex
  • OnlinePlayerRegex

tibia

  • characterNameRegex
  • creatureAndSpellNameRegex
  • guildNameRegex
Original TLDR
I decided to open this issue in order to track the progress of removing all regex from the system.

Reducing the amount of regex is beneficial for two main reasons:

  1. Speed
  • When parsing without regex, it is quicker
  1. Heap Allocations
  • Even though we already made the regexes sentinel value, not having to compile them on every iteration, using the compiled regex still make heap allocations. So, by removing regexes completely we reduce a lot of heap allocations, thus reducing the GC load.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions