Skip to content

API usage guidelines #22994

@DonJayamanne

Description

@DonJayamanne

It feels like accessing the known property can result in a lot of code getting executed, even if its just logging (i.e. 1,500 entries in a few seconds is a lot of logging).

Here #22993

Also looking at the code in Python extension

        get known(): Environment[] {
            sendApiTelemetry('known');
            return discoveryApi
                .getEnvs()
                .filter((e) => filterUsingVSCodeContext(e))
                .map((e) => convertEnvInfoAndGetReference(e));
        },

There's a lot going on here, hence it feels like I (as a a user of the above API) would need to be careful accessing this 100s of times.
As this could unnecessarily chew CPU,

Question

  • Should we (consumers of the API) cache the value of known
  • Is it possible for Python extnsion to instead cache the known value into a property, after all there are events for triggering the changes, hence that feels like its doable.

Anyways, asking this as I fear that changes in Jupyter to now access know everytime we need somethign is actually going to slow the extnsion host significantly as theres a lot going on here,
I.e. calling this 100s of times in a few ms could cause issues (after all this is what I was experiencing)

Note:

  • When I opened the Jpuyter kernel picker and attempted to select a Python environment, I did notice some sluggishness in the UI
  • Possible it was unrelated, but I thought of checking the logs and then saw the logging and then looked at the API implementation, hence this issue

Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions