krassowski / jupyterlab-citation-manager

Citation Manager for JupyterLab using Zotero Web API
BSD 3-Clause "New" or "Revised" License
61 stars 2 forks source link

Debugger slows down Jupyterlab #77

Open Michael-ljn opened 2 months ago

Michael-ljn commented 2 months ago

Hi,

First of all, thank you for this awesome extension. I just installed the latest version V1.0.0 and somehow the extension is considerably slowing down my JupyterLab server. Sometimes it makes it freeze. The following lines are in the terminal log which indicates that some sort of debugger is on.

0.00s - Debugger warning: It seems that frozen modules are being used, which may 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off 0.00s - to python to disable frozen modules. 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

I am certain it is from this extension, as I do not experience this problem when the extension is disabled. Not sure what causes this but wonder if we can disable it, at a software level. Maybe downgrading to a more stable version?

I am a mac user, on M1pro chip.

krassowski commented 2 months ago

This extension (citation-manager) has nothing to do with the debugger. However, I know how to resolve the warning you are seeing:

  1. Upgrade to ipykernel 6.29.4
  2. Run python -m ipykernel install --sys-prefix (assuming you have the ipykernel installed in a virtual environment; if not, you need to pass appropriate --prefix argument)

Note, this does not mean that the debugger is on. However, from the warning I can say that you are running Python 3.11+. If you do not see the warning, nor slowness in another environment you have either created it recently with the update ipykernel, or have an older Python version.

considerably slowing down my JupyterLab server

Can you share the full logs after running jupyter lab --debug?

krassowski commented 2 months ago

If anything is slowing down the startup that would likely be the scanning for citation style files:

https://github.com/krassowski/jupyterlab-citation-manager/blob/1883d78385f41832b2a29edd67439354c67e1c57/jupyterlab_citation_manager/styles.py#L60-L83

It should be possible to make all the logic async so that it does not block the server startup.

Michael-ljn commented 2 months ago
  • Upgrade to ipykernel 6.29.4
  • Run python -m ipykernel install --sys-prefix (assuming you have the ipykernel installed in a virtual environment; if not, you need to pass appropriate --prefix argument)

Updating ipykernel effectively removed the debugger lines in the terminal. I think you are right, the huge lag comes from the Zotero sync or at least from what I understand. It's very laggy and freezes the server when you have multiple notebooks open, and you switch between them. Is that because of the _scan_for_styles()?

I will try to dive a bit more in this in the coming weeks.

Michael-ljn commented 2 months ago

There is also a bunch of non-citable content that is being fetched from the API. I can see annotations from pdf and notes and have to carefully select the good zotero item. Could that be also a reason why the sync is so slow? Is there a way to return only the citable content?