codebytere / codebytere/node-mac-contacts

Slow performance with lots of contacts

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
performance
Dominant language
Objective-C++
Stars
86
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Since my app was being very slow on their computer (MBP 16" 2019), I got a friend to run this:

```js
const nmc = require('node-mac-contacts')
console.time('done')
const c = nmc.getAllContacts(['contactImage', 'contactThumbnailImage', 'jobTitle', 'departmentName', 'organizationName', 'middleName', 'note', 'socialProfiles'])
console.log(c.length, 'contacts')
console.timeEnd('done')
```

It took 16s for ~4k contacts.

> 3705 contacts
> done: 16798.31201171875ms

Thought it might be the image buffers so asked them to run:
```js
console.time('done')
console.log(require('node-mac-contacts').getAllContacts().length, 'contacts')
console.timeEnd('done')
```

It still took 12s.

Any ideas on how to make it faster or debug this? I created 4k contacts with a first and last name on my Mac but it didn't slow it up much:

> 4135 contacts
> done: 319.488037109375ms

I'll use a worker and cache the results as a workaround. I'm curious why it takes so long.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported getAllContacts benchmarks on macOS with and without the listed contact fields, comparing the 16-second and 319-ms cases. Trace the node-mac-contacts implementation to identify why similar contact counts differ so greatly; done means the cause is understood and a measurable performance improvement or clear limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, node.js, objective-c
Domain
desktop, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.