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

Experiment/use mashumaro #2885

Closed
wants to merge 5 commits into from

Conversation

drewbanin
Copy link
Contributor

Draft PR - do not merge this.

Example script to assess perf gains:

import dbt
import dbt.adapters.postgres.relation
import time

Relation = dbt.adapters.postgres.relation.PostgresRelation

N = 10000

t_create = 0
t_to_dict = 0
t_from_dict = 0
for i in range(N):
    step_1 = time.time()
    rel = Relation.create(database='debug', schema='debug', identifier='debug')
    step_2 = time.time()
    as_dict = rel.to_dict()
    step_3 = time.time()
    from_dict = Relation.from_dict(as_dict)
    step_4 = time.time()

    t_create += step_2 - step_1
    t_to_dict += step_3 - step_2
    t_from_dict += step_4 - step_3

total = t_create + t_to_dict + t_from_dict

print(f"create: {t_create:0.2f} ({t_create / N:0.4f} per node)")
print(f"to_dict: {t_to_dict:0.2f} ({t_to_dict / N:0.4f} per node)")
print(f"from_dict: {t_from_dict:0.2f} ({t_from_dict / N:0.4f} per node)")
print(f"total: {total:0.2f} ({total / N:0.4f} per node)")

Timing

Branch Cycles Time
experiment/use-mashumaro 100 0.00s
experiment/use-mashumaro 1000 0.04s
experiment/use-mashumaro 10000 0.23s
kiyoshi-kuromiya 100 0.36s
kiyoshi-kuromiya 1000 3.54s
kiyoshi-kuromiya 10000 33.95s

kiyoshi-kuromiya avg: 3.4ms / iteration
experiment/use-mashumaro avg: 0.023ms / iteration

So that's like a ~170x improvement :)

@jtcohen6
Copy link
Contributor

jtcohen6 commented Feb 8, 2021

Closing on account of #3034 :)

@jtcohen6 jtcohen6 closed this Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants