-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 delete & insert performance #94
Improve delete & insert performance #94
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why your PR is still not approved? Because I chose not to approve it. But they will.
2356887
to
1fc35af
Compare
dfb1681
to
6abb108
Compare
This PR has been rebased and is ready for review 👍 |
6abb108
to
1c1709d
Compare
1c1709d
to
ebce159
Compare
I'll run some benchmarking on this too and report back. |
Here're the relevant comparisons between current master and this branch:; TLDR;
Insertmaster
new
We don't currently have delete benchmarks, so I'll look at adding those, but given the implementation I'd expect the same level of speedup. Looking over these benchmarks it may be a good Hacktoberfest project for someone, although it's certainly true that benchmarks are surprisingly difficult to get right 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisPenner That's impressive work! Small changes, but huge performance boost 🚄 Very nice benchmark results! And if you think that some of the benchmarks can be improved, I would encourage you to open a separate issue and discuss possible improvements 👍
delete = fromTriples . deleteByFst (typeFp @a) . toTriples | ||
delete m | ||
-- Lookups are fast, so check if we even have the element first. | ||
| not (member @a m) = m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that's an interesting idea! Very nice optimization 👍
I wonder, if we can do something like that for insert
? For example, if the element exists, we can just update the array cell and copy the whole array instead of moving from one ordering to another.
But I guess, this will require some work, and probably be done under a separate issue 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a separate issue for future insert
improvements: #99
insert = union (one x)
gives O(n) inserts, still not great; but better thanO(nlogn)
delete
: UsingtoSortedTriples
, which is anO(n)
way to get a sorted list of triples, we can simply filter out the offending element and rebuild inO(n)
total timeAddresses #57
This should be rebased on top of #93 once it's merged,
In the meantime; these are the relevant commits from just this PR