How to improve response time on USB insertion?

When my user inserts a usb memory stick I want to show a quick response in my application. Now it takes close to 3 seconds before the USB drive is mounted. Is it possible to reduce this time?

Here an excempt from the logging when inserting a USB drive:

Tue Jun 30 20:16:55 2020 kern.info kernel: [  621.695598] usb 1-1: new high-speed USB device number 5 using ehci-platform
Tue Jun 30 20:16:55 2020 kern.info kernel: [  621.921996] usb-storage 1-1:1.0: USB Mass Storage device detected
Tue Jun 30 20:16:55 2020 kern.info kernel: [  621.955596] scsi host0: usb-storage 1-1:1.0
Tue Jun 30 20:16:55 2020 user.notice root: testlog YES!!!!!
Tue Jun 30 20:16:56 2020 kern.notice kernel: [  622.976969] scsi 0:0:0:0: Direct-Access     USB 2.0  Flash Disk       1100 PQ: 0 ANSI: 0 CCS
Tue Jun 30 20:16:56 2020 kern.notice kernel: [  622.990157] sd 0:0:0:0: [sda] 990208 512-byte logical blocks: (507 MB/484 MiB)
Tue Jun 30 20:16:56 2020 kern.notice kernel: [  623.005593] sd 0:0:0:0: [sda] Write Protect is off
Tue Jun 30 20:16:56 2020 kern.debug kernel: [  623.010531] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
Tue Jun 30 20:16:56 2020 kern.err kernel: [  623.032037] sd 0:0:0:0: [sda] No Caching mode page found
Tue Jun 30 20:16:56 2020 kern.err kernel: [  623.037543] sd 0:0:0:0: [sda] Assuming drive cache: write through
Tue Jun 30 20:16:56 2020 kern.info kernel: [  623.274030]  sda: sda1
Tue Jun 30 20:16:56 2020 kern.notice kernel: [  623.283487] sd 0:0:0:0: [sda] Attached SCSI removable disk
Tue Jun 30 20:16:57 2020 kern.warn kernel: [  624.085781] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

In /etc/hotplug.d/usb/20-autorun I added a log line "YES!!!" which was logged within 1 second after insertion. I added a sleep(4) here, but even that delay is not always long enough for the drive to be properly accesible on the mounted location.

Questions:

  1. Is it possible to speed up the mount process? Perhaps reduce the number of supported file types? etc?
  2. I hate the hard coded timeout. Is it possible to be signalled when the usb drive finished mounting?

Have you noticed this and have you run fsck as instructed?

Thanks for pointing out the drive was not properly unmounted, but that doesn't change the long timing.
Here a new log with the drive properly unmounted:

Tue Jun 30 21:19:56 2020 kern.info kernel: [  551.413097] usb 1-1: new high-speed USB device number 3 using ehci-platform
Tue Jun 30 21:19:56 2020 kern.info kernel: [  551.639677] usb-storage 1-1:1.0: USB Mass Storage device detected
Tue Jun 30 21:19:56 2020 kern.info kernel: [  551.673112] scsi host0: usb-storage 1-1:1.0
Tue Jun 30 21:19:57 2020 user.notice root: testlog YES!!!!!!!!!!!!!!!
Tue Jun 30 21:19:57 2020 kern.notice kernel: [  552.734539] scsi 0:0:0:0: Direct-Access     USB 2.0  Flash Disk       1100 PQ: 0 ANSI: 0 CCS
Tue Jun 30 21:19:57 2020 kern.notice kernel: [  552.748474] sd 0:0:0:0: [sda] 990208 512-byte logical blocks: (507 MB/484 MiB)
Tue Jun 30 21:19:57 2020 kern.notice kernel: [  552.763139] sd 0:0:0:0: [sda] Write Protect is off
Tue Jun 30 21:19:57 2020 kern.debug kernel: [  552.768054] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
Tue Jun 30 21:19:57 2020 kern.err kernel: [  552.773354] sd 0:0:0:0: [sda] No Caching mode page found
Tue Jun 30 21:19:57 2020 kern.err kernel: [  552.778782] sd 0:0:0:0: [sda] Assuming drive cache: write through
Tue Jun 30 21:19:58 2020 kern.info kernel: [  553.000475]  sda: sda1
Tue Jun 30 21:19:58 2020 kern.notice kernel: [  553.010128] sd 0:0:0:0: [sda] Attached SCSI removable disk

Still the same 2.5 seconds for mounting a FAT16 formatted drive.

Sorry, my arithmetics are off.
With the drive properly mounted the last log message is skipped, this saves 0.8s in the total logging time.
The time required for mounting the drive is equal in both situations (properly unmounted or not): 1.6 seconds.
I'm wondering if this time can be improved upon?