Skip to content

Conversation

@osmaczko
Copy link
Contributor

What does the PR do

closes: #10797

Affected areas

  • contact details

@osmaczko osmaczko requested review from a team, borismelnik and igor-sirotin and removed request for a team May 25, 2023 11:49
@status-im-auto
Copy link
Member

status-im-auto commented May 25, 2023

Jenkins Builds

Click to see older builds (28)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 2eb2587 #1 2023-05-25 11:57:30 ~8 min tests/imports 📄log
✔️ 2eb2587 #1 2023-05-25 11:58:17 ~8 min tests/nim 📄log
✔️ 2eb2587 #1 2023-05-25 11:59:12 ~9 min macos/aarch64 🍎dmg
✔️ 2eb2587 #1 2023-05-25 12:00:25 ~11 min macos/x86_64 🍎dmg
✔️ 2eb2587 #1 2023-05-25 12:05:22 ~16 min linux/x86_64 📦tgz
✔️ 2eb2587 #1 2023-05-25 12:24:45 ~35 min windows/x86_64 💿exe
✖️ 2eb2587 #1 2023-05-25 12:43:02 ~53 min tests/e2e 📄log
✔️ 2eb2587 #3 2023-05-25 14:59:04 ~5 min macos/aarch64 🍎dmg
✔️ 2eb2587 #3 2023-05-25 15:01:48 ~8 min macos/x86_64 🍎dmg
✔️ 2eb2587 #3 2023-05-25 15:04:02 ~10 min tests/imports 📄log
✔️ 2eb2587 #3 2023-05-25 15:05:15 ~11 min tests/nim 📄log
✔️ 2eb2587 #3 2023-05-25 15:07:48 ~14 min linux/x86_64 📦tgz
✔️ 2eb2587 #3 2023-05-25 15:18:20 ~24 min windows/x86_64 💿exe
✖️ 2eb2587 #3 2023-05-25 16:11:00 ~1 hr 17 min tests/e2e 📄log
✔️ 6b69068 #2 2023-05-25 14:17:27 ~5 min macos/aarch64 🍎dmg
✔️ 6b69068 #2 2023-05-25 14:20:51 ~9 min tests/imports 📄log
✔️ 6b69068 #2 2023-05-25 14:20:53 ~9 min macos/x86_64 🍎dmg
✔️ 6b69068 #2 2023-05-25 14:21:56 ~10 min tests/nim 📄log
✔️ 6b69068 #2 2023-05-25 14:28:23 ~16 min linux/x86_64 📦tgz
✔️ 6b69068 #2 2023-05-25 14:44:57 ~33 min windows/x86_64 💿exe
✔️ 42489ed #4 2023-05-25 17:31:03 ~5 min tests/imports 📄log
✔️ 42489ed #4 2023-05-25 17:31:55 ~5 min tests/nim 📄log
✔️ 42489ed #4 2023-05-25 17:31:59 ~6 min macos/aarch64 🍎dmg
✔️ 42489ed #4 2023-05-25 17:35:08 ~9 min macos/x86_64 🍎dmg
✔️ 42489ed #4 2023-05-25 17:42:59 ~17 min linux/x86_64 📦tgz
✔️ 42489ed #4 2023-05-25 17:54:53 ~28 min windows/x86_64 💿exe
✖️ 42489ed #4 2023-05-25 18:43:09 ~1 hr 17 min tests/e2e 📄log
✖️ 42489ed #5 2023-05-25 22:14:29 ~51 min tests/e2e 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
67c98ea #5 2023-05-30 07:28:36 ~4 min macos/aarch64 📄log
✔️ 67c98ea #5 2023-05-30 07:29:17 ~5 min tests/imports 📄log
✔️ 67c98ea #5 2023-05-30 07:29:35 ~5 min tests/nim 📄log
✔️ 67c98ea #5 2023-05-30 07:32:56 ~9 min macos/x86_64 🍎dmg
✔️ 67c98ea #5 2023-05-30 07:38:13 ~14 min linux/x86_64 📦tgz
✔️ 67c98ea #5 2023-05-30 07:52:15 ~28 min windows/x86_64 💿exe
✖️ 67c98ea #6 2023-05-30 08:15:23 ~51 min tests/e2e 📄log
✖️ 67c98ea #7 2023-05-30 11:00:03 ~1 hr 7 min tests/e2e 📄log
475eb58 #6 2023-05-31 09:00:11 ~4 min macos/aarch64 📄log
475eb58 #6 2023-05-31 09:02:18 ~6 min macos/x86_64 📄log
✔️ 475eb58 #6 2023-05-31 09:06:37 ~10 min tests/nim 📄log
✔️ 475eb58 #6 2023-05-31 09:06:45 ~11 min tests/imports 📄log
✔️ 475eb58 #6 2023-05-31 09:11:46 ~16 min linux/x86_64 📦tgz
✔️ 475eb58 #6 2023-05-31 09:23:53 ~28 min windows/x86_64 💿exe
✔️ 475eb58 #8 2023-05-31 09:41:46 ~46 min tests/e2e 📄log

Copy link
Contributor

@igor-sirotin igor-sirotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

This implementation looks good to me, but I wonder if everything that we have in ContactDetails should actually be in status-go 🤔 E.g. mobile will have to duplicate the logic of name/optionalName.

## same image and name displayed everywhere in the app.
result.name = contactDto.userDefaultDisplayName()
result.optionalName = contactDto.userOptionalName()
if(contactDto.image.thumbnail.len > 0):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this code was here already, but just noticed that this condition looks quite suspicious and doesn't make sense to me. Didn't dig deepers, but looks smth like if a user removes profile image, we will not process the update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, seems so 🤔 We would need to check if that's really the case.

# of contacts. Be sure when you change any condition here.
let myPubKey = singletonInstance.userProfile.getPubKey()
let contacts = toSeq(self.contacts.values)
let contacts = toSeq(self.contacts.values).map(cd => cd.dto)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe return seq[ContactsDetails] from this function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called with getContacts in initContactRequestsModel.
And then for each contact we call createItemFromPublicKey which calls getContactDetails.

So we do have ContactDetails in the beginning, then switch it to ContactDto and eventually back to ContactDetails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I will address that in a follow-up PR to keep this one compact and avoid potential conflicts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: #10807

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Nice job.

Thank you for changing contactDetails.details to contactDetails.dto. IMO, it never made sense to have details inside something that is a already [contact]Details.

trustStatus: TrustStatus.Trusted,
bio: self.settingsService.getBio(),
socialLinks: self.settingsService.getSocialLinks()
return self.constructContactDetails(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make me wonder, can't we save our own ContactDetails in a cache? Maybe here or in the singleton. That way we don't have to reprocess it each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Addressed: 6b69068

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure to update the cache when we update our profile though. It can be done in another PR if you want. (just remove the commit and put it in another branch)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, haven't thought of it 👍

if(self.contacts.hasKey(pubkey)):
return self.contacts[pubkey]

result = self.fetchContact(pubkey)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that we may hit the DB here, so it's a possible case where we could have a freeze. That may explain why we still see freezes when switching.

No need to fix here, but something to consider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't seen that as a culprit in profiled data, although yes, we should make all potential DB hits async. I would leave it as is for now, otherwise it will complicate logic of getting contact details a lot.

@osmaczko
Copy link
Contributor Author

This implementation looks good to me, but I wonder if everything that we have in ContactDetails should actually be in status-go E.g. mobile will have to duplicate the logic of name/optionalName.

Good point. As far as I know mobile is using media server for color hash and we are drawing it by our own on qml scene. Other fields we can probably move to status-go's ContactsDto, although we would need to sync with mobile if they will take advantage of such extension.

@osmaczko osmaczko force-pushed the chore/cache-contact-details branch 2 times, most recently from 2eb2587 to 42489ed Compare May 25, 2023 17:25
@igor-sirotin
Copy link
Contributor

Good point. As far as I know mobile is using media server for color hash and we are drawing it by our own on qml scene. Other fields we can probably move to status-go's ContactsDto, although we would need to sync with mobile if they will take advantage of such extension.

Yeah, good plan 👍
Probably doesn't make sense to implement now, but maybe consider with c++ app 🙂

@osmaczko osmaczko force-pushed the chore/cache-contact-details branch from 42489ed to 67c98ea Compare May 30, 2023 07:23
@osmaczko osmaczko force-pushed the chore/cache-contact-details branch from 67c98ea to 475eb58 Compare May 31, 2023 08:55
@osmaczko osmaczko merged commit c40472c into master May 31, 2023
@osmaczko osmaczko deleted the chore/cache-contact-details branch May 31, 2023 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] cache ContactDetails

5 participants