Skip to content

Typora Snap takes a very long time to start the first time since PC boot #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hsandt opened this issue Dec 17, 2024 · 4 comments
Open

Comments

@hsandt
Copy link

hsandt commented Dec 17, 2024

Typora Snap version: v1.9.3

When starting Typora Snap for the first time since PC boot, it takes a very long time to start (about 10 seconds).

This only happens with the Snap version.

@predr
Copy link
Contributor

predr commented Dec 17, 2024

It's a confined electron app. Some slowness is expected on first start while environment is being setup.

With that said, I'm getting about 5s for first and 2s for second startup. I think it can be improved to 2s first and 1s second startup using compression: lzo, though it will be 35% larger in size. Using newer base: core22 or base: core24 could also improve startup speed.

I'll do some more testing and offer a PR.

@hvbakel
Copy link

hvbakel commented Apr 4, 2025

You can try adding the following config option to increase startup speed. I believe (but am not 100% sure) that xz is still the default compression format. See https://snapcraft.io/blog/why-lzo-was-chosen-as-the-new-compression-method for more details.

compression: lzo

@predr
Copy link
Contributor

predr commented Apr 10, 2025

First, I have found a script to more accurately test launch times. This is for X, I don't know what Wayland equivalent would look like.

#!/bin/bash
function close-window {
    for window in $(xdotool search --sync --onlyvisible --class "$1"); do
        xdotool getwindowpid "$window" | xargs kill;
    done
}
close-window "$1" & time snap run "$1"

Here are median launch times vs. compression for current snap (in seconds, depends on hardware):

XZ (default) LZO
First launch 4.720 1.593
Second launch 1.080 1.081

These times are same for previous core20 and current core22 snap.

Snap compression only affects first lauch while SquasFS is being unpacked. Most snap maintainers, if not all, have opted to ignore the default space saving option XZ and use LZO compression for faster first startup.

https://forum.snapcraft.io/t/an-investigation-into-snap-startup-speed/14619
https://snapcraft.io/docs/snap-performance

Checking connected interfaces in wrapper script takes 0.077s.

Then I started working on core24 and looking into GPU acceleration. There are GPU content snaps being developed with drivers and wrappers in them. These are auto-connected in gnome extension for core24 snaps providing out-of-box GPU acceleration.

https://mir-server.io/docs/the-gpu-2404-snap-interface
https://snapcraft.io/docs/gnome-extension

Here is nvtop showing Typora GPU usage.

Image

Median launch times for core24 was 1.079s for 5 launches. Looks like, time saved by removing wrapper script is spent on other wrapper scripts provided by gnome extension, remaining same in the end.

Some additional stuff:

  • changed outdated description, taken from website
  • removed plugs provided by gnome extension
  • removed plugs/slots not auto-connected/needed
  • removed stage packages provided by gnome extension
  • tested opening and exporting documents

I have opened a pull request with all these improvements. May I also suggest a small testing period in candidate channel.

@predr
Copy link
Contributor

predr commented May 25, 2025

Another command to observe environment being setup is:

snap run --trace-exec typora

It's output looks like this (removed standard application output):

...
Slowest 10 exec calls during snap run:
  0.042s /snap/snapd/24505/usr/lib/snapd/snap-confine
  0.024s /snap/typora/x2/snap/command-chain/gpu-2404-wrapper
  0.092s /snap/typora/x2/snap/command-chain/desktop-launch
  0.021s /usr/bin/head
  0.021s /usr/bin/cat
  0.039s /bin/sh
  3.312s /proc/self/exe
  25.163s /proc/self/exe
  25.440s /proc/self/exe
  26.141s /snap/typora/x2/Typora
Total time: 26.354s

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

No branches or pull requests

3 participants