greatscottgadgets / packetry

A fast, intuitive USB 2.0 protocol analysis application for use with Cynthion.
BSD 3-Clause "New" or "Revised" License
140 stars 29 forks source link

Saving a pcap takes minutes #169

Closed claui closed 2 months ago

claui commented 2 months ago

On Packetry 0.2.0, saving captured packets to a pcap file usually takes minutes, while loading is instant.

Steps to reproduce

  1. Open Packetry.
  2. Load any pcap file from your local file system. Observe that the file loads instantly, i.e. within tenths of seconds for a ~100MB pcap file.
  3. Press the Save button on the toolbar. A file chooser comes up.
  4. In the file chooser, pick a file name and hit Save.
  5. Watch the progress bar near the bottom of the window:

image

Expected behavior

Saving a ~100MB pcap file, originally recorded and saved using Packetry, takes about three minutes on a fast SSD.

Actual behavior

Saving a ~100MB pcap file, originally recorded and saved using Packetry, takes less than 30 seconds on a fast SSD.

Affected builds

This has occurred as long as I can remember. I only learned today via Discord that it’s not supposed to be that slow.

Builds with which I can reproduce the symptom:

Notes

The above steps use a previously-saved pcap file for convenience. However, the same symptoms occur when saving a fresh Cynthion-recorded file.

Packetry says that the pcap file I’ve used has ~2.7M transactions and ~5.5M packets.

depili commented 2 months ago

I can confirm this on macos with cargo run --release and 71827e2fcdcf227b3bbdab93b67cf4893f169e54

Saving a full speed 56 second capture of a ftdi-ft serial traffic with 4.13MiB reported size in packetry took around 5 minutes to save the 4,3M captured packets. This resulted in 75MB .pcap file.

martinling commented 2 months ago

I've been unable to reproduce this here. I have a 300MB file I use regularly for benchmarking, with 1.5M transactions and 3.5M packets, and it saves in about 5 seconds on a release build. On a debug build it takes a couple of minutes.

martinling commented 2 months ago

Turned out my file was a poor test because it used old dummy timestamp data. With a fresh capture I could reproduce the problem. Fixed in #170.

claui commented 2 months ago

Thank you for the fix @martinling!