Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Better ReferenceCounter branch[tarjin-2] #460

Closed
wants to merge 1 commit into from
Closed

Conversation

erikzhang
Copy link
Member

(Maybe) an optimized version of #459

@erikzhang erikzhang changed the base branch from master to tarjan May 8, 2022 22:16
@erikzhang
Copy link
Member Author

We need to test which one is better, this or #459?

@dusmart
Copy link

dusmart commented May 9, 2022

test with old PoC VgEMAkABSotKi0qLSotKi0qLSotKi0qLSotKiwH4D40MAkAAixHAAQAEYFidYEofDAtkZXNlcmlhbGl6ZQwUwO85zuDk6SXGwqBqeeFEDdhvzqxBYn1bUkVYJNFJ from Tanya-6

tarjin-2 cost 0:00:07
tarjan cost 0:00:09
no-optimization cost 0:05:26
tarjin-3-switch 0:00:04
optimize-reference-counter 0:00:06

it's a huge improvement

@dusmart
Copy link

dusmart commented May 9, 2022

test with a PoC derived from Tanya-4 whose itration number is 3800 instead of 380000 (otherwise the time will be longer)

VwEAwkpKAfsHdwARwG8AnXcAbwAl9////xHAzwHYDncAEM5vAJ13AG8AJff///9F

tarjan => 0:00:21
tarjan-2 => 0:00:15
no-optimization => 0:00:01

Tanya-4 and Tanya-6 is the only two issues which have not been fixed thoroughly.

if we set iteration number to 38000 which is VwEAwkpKAfsHdwARwG8AnXcAbwAl9////xHAzwJwlAAAdwAQzm8AnXcAbwAl9////0U=

tarjan => 0:01:09
tarjan-2 => 0:02:01
no-optimization => 0:00:12
tarjan-3-swtich => 0:00:27
optimize-reference-counter => 0:00:49

I'm trying my best to do the time complexity analysis ...... This result is weird for me

@dusmart
Copy link

dusmart commented May 9, 2022

Here are the differences between Tanya-4 and Tanya-6.

Poc Tanya-4 Tanya-6
iteration op PICKITEM deserialize+drop
iteration num 380000 1024
operation target [[[ ...2044... ]]] end-to-end loop array [[[ ...2046... ]]] simple nested array
best GC no-optimization tarjin-2
no-optimization time complexity O(n) O(n2)
no-optimization graph image image
tarjan-2 time complexity O(n) O(n)
tarjan-2 graph tarjan is O(E+V) the same as left

@dusmart
Copy link

dusmart commented May 9, 2022

Actually, to prevent Tanya-6, we only need to optimize the AddReference like this:

image

I've tested this with Tanya-6, 0:00:02 cost.

@dusmart
Copy link

dusmart commented May 9, 2022

The best time complexity for GC is O(n), therefore Tanya-4 is hard to prevent. And at this time, there are lots of other O(n) issues such as Bytes opration. Just ignore Tanya-4 will be an understandable choice.

In a certain point of view, neo-project/neo#2725 is also a variant of Tanya-4, the GetNotification syscall creates lots of small object and the dropping will cause a slow GC.

@erikzhang erikzhang changed the title Better ReferenceCounter (maybe an optimized version) Better ReferenceCounter branch[tarjin-2] May 9, 2022
@erikzhang
Copy link
Member Author

@dusmart I've made some improvements based on tarjin-2. Please check #461

@dusmart
Copy link

dusmart commented May 10, 2022

@dusmart I've made some improvements based on tarjin-2. Please check #461

Tanya-6 cost 0:00:06 which is still a huge improvement compared to no-optimization.
Tanya-4 with 38000 iteration cost 0:01:25 which is similar to tarjin-2.

The result is based on the cheapest MacBookAir with m1 chip and release version of dotnet6.0.
The result is not that stable.

After testing many times with Tanya-4 and iteration number set to 10000, tarjin-3 cost 0:00:25 while tarjin-2 cost 0:00:34 adn tarjan cost 0:00:18. They all have a O(n) time complexity in this case.

@erikzhang
Copy link
Member Author

#463 is the best. Closed this one.

@erikzhang erikzhang closed this May 11, 2022
@erikzhang erikzhang deleted the tarjin-2 branch May 11, 2022 10:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants