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

PagedMemory: Use dicts to store items when there are only a few. #3471

Merged
merged 4 commits into from Sep 5, 2022

Conversation

ltfish
Copy link
Member

@ltfish ltfish commented Aug 3, 2022

TODO:

  • Fix the type annotation for DynamicDictList to support DynamicDictList[element_type].
  • Write a performance test case to determine the optimal threshold.

@ltfish ltfish added the feature Adding a new control knob to something label Aug 3, 2022
@github-actions
Copy link

github-actions bot commented Aug 3, 2022

Unit Test Results

     81 files  ±0       81 suites  ±0   1h 26m 46s ⏱️ + 17m 13s
1 089 tests ±0  1 059 ✔️ ±0  30 💤 ±0  0 ±0 
1 095 runs  ±0  1 065 ✔️ ±0  30 💤 ±0  0 ±0 

Results for commit 5cd4514. ± Comparison against base commit af6f718.

♻️ This comment has been updated with latest results.

@ltfish ltfish force-pushed the feat/dynamicdictlist branch 2 times, most recently from d35b68b to a280286 Compare August 4, 2022 08:14
@ltfish
Copy link
Member Author

ltfish commented Aug 30, 2022

Apparently this is never merged (or finished). I'll get to it today.

@ltfish
Copy link
Member Author

ltfish commented Sep 5, 2022

My profiling script:

import matplotlib.pyplot as plt
import timeit


NUMBER = 10000


def profile_list_dict(elements: int):
    t0 = timeit.Timer("dict(d)", setup=f"""
class A:
    pass

d = dict((v, A()) for v in range({elements}))""")

    t1 = timeit.Timer("list(l)", setup=f"""
class A:
    pass

l = [None] * 4096
for i in range({elements}):
    l[i] = A()""")

    d = t0.timeit(number=NUMBER)
    l = t1.timeit(number=NUMBER)
    print("#:", elements)
    print("dict:", d)
    print("list:", l)
    return d, l


def main():
    d_ = [ ]
    l_ = [ ]
    tt = [ ]
    for elements in range(0, 4096, 50):
        d, l = profile_list_dict(elements)
        tt.append(elements)
        d_.append(d)
        l_.append(l)

    # plot it
    fig, ax = plt.subplots()
    ax.plot(tt, d_, label="dict")
    ax.plot(tt, l_, label="list")
    ax.legend()

    plt.savefig("result.png")
    plt.show()


if __name__ == "__main__":
    main()

CPython 3.10:

cpy310

PyPy 3.9:

pypy39

Looks like we need two different thresholds :/

ltfish added a commit to angr/angr-doc that referenced this pull request Sep 5, 2022
ltfish added a commit to angr/angr-doc that referenced this pull request Sep 5, 2022
@ltfish ltfish merged commit e4e1655 into master Sep 5, 2022
@ltfish ltfish deleted the feat/dynamicdictlist branch September 5, 2022 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding a new control knob to something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants