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

[feat] Refactor Benzina #29

Merged
merged 25 commits into from
Oct 10, 2024
Merged

[feat] Refactor Benzina #29

merged 25 commits into from
Oct 10, 2024

Conversation

subiabre
Copy link
Member

@subiabre subiabre commented Oct 10, 2024

All the way back in #2 it was added a small ad-hoc library named Benzina with a simple, two piece, concept:

  1. Read data in a stream manner via StreamInterface.
  2. Write data from the streams to any storage via PumpInterface.

Benzina allows us to load data batches of n records from the tables in the old Goteo v3 database and feed them to available (i.e: they support the data in the table records) Pumps that transform the data into v4 entities and stores it in the Goteo v4 database.

But after several heavy work done on v4, Benzina had been left unattended and fallen outdated, as the implemented Pumps had fallen out of sync with the usage of the entities they were meant to pump data to and the library was also remarkably slow and memory-hungry.

Heavy profiling was performed on the library and the following issues were brought to light and then fixed:

  • The entities were updated with database indexes to improve already-pumped data lookups.
  • Pumped progress code was refactored to allow tailoring for Doctrine's specifics and memory usage was improved using a slicing strategy. The input batch is fed to DoctrinePumpTrait::skipPumped which returns the input batch minus the already-pumped records in the batch. This allows to reduce associated pumped data lookups for the batch such as users and projects by allowing the pump to only work with un-pumped data in a batch, effectively skipping already-pumped data from all processes.
  • GatewayCheckout associated data such as GatewayLinks and GatewayTrackings was simplified from fully-qualified related entities to plain-old PHP objects stored in the checkouts as JSON to reduce Doctrine's unit-of-work overhead having to cascade persist to extra database tables.

@subiabre subiabre added bug Something isn't working enhancement New feature or request labels Oct 10, 2024
@subiabre subiabre requested a review from davidbeig October 10, 2024 18:18
@subiabre subiabre self-assigned this Oct 10, 2024
@subiabre subiabre merged commit 05afe72 into main Oct 10, 2024
2 checks passed
@subiabre subiabre deleted the feat/benzina-refactor branch October 10, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant