Skip to content

Investigate the cases where s3fs outperforms the S3 filesystem #1424

Open

Description

@laughingman7743

Summary

The re-measurement for #1315 (history entry, #1420) found s3fs ahead of PyAthena's filesystem in five places: downloads of many objects, info() and copy at concurrency 40, threads and CPU time, and requests sent one at a time.
Before the filesystem is published as an s3fs alternative (#1315), find the cause of each gap, check that it reproduces, and file a fix for each gap that has one.

Gaps

The numbers are from the medium set, 1,000 objects of 1 MiB, on Python 3.12, with one c8gn.2xlarge host per run.
"Times" is s3fs's throughput divided by PyAthena's, for the synchronous / aio filesystem.

  1. get of many objects.
    • On 2026-11-15, s3fs ran at 1.40 / 1.44 times at concurrency 8 and 1.42 / 1.51 times at concurrency 40.
    • On 2026-10-23, it ran at 1.13 and 0.72 times the aio filesystem; the synchronous one still downloaded one object at a time.
    • Between the two runs, the aio filesystem's throughput went from 160 to 167 objects per second at concurrency 8 and from 286 to 252 at 40, and s3fs's from 180 to 240 and from 205 to 380.
    • On free-threaded Python 3.15t at concurrency 40, the synchronous and aio filesystems downloaded 680 and 661 objects per second, and s3fs 340.
    • From the code, not measured: get_file() calls isdir(), which sends HeadObject, and the file that it then opens reuses the cached result and reads the object with a range GetObject conditional on its ETag.
      s3fs's _get_file() sends one GetObject.
      On the same set, PyAthena ran cat, which sends one GetObject per object, at 1.43 to 1.54 times s3fs's throughput.
  2. info() at concurrency 40.
    • s3fs ran at 1.31 / 1.47 times on 2026-11-15 and 1.35 / 1.45 times on 2026-10-23; at concurrency 8, at 1.04 / 1.05 and 1.09 / 1.09 times.
    • The PyAthena processes took 1.42 / 1.53 seconds of CPU time against s3fs's 0.85 on 2026-11-15.
    • On Python 3.15t, the synchronous filesystem ran 1,792 lookups per second and s3fs 1,001.
    • The runs did not profile the cause; contention for the GIL among the 40 threads is suspected.
  3. copy at concurrency 40.
    • s3fs ran at 1.15 / 1.23 times on 2026-11-15 and 1.20 times the aio filesystem on 2026-10-23, and at 0.96 to 1.08 times at concurrency 8.
    • The runs did not count the requests of a copy.
  4. Threads and CPU time.
    • At concurrency 40, the PyAthena processes peaked at 51 or 52 threads in the transfers and info(), and at 91 or 92 in downloads, whose files read their ranges in the request pool; s3fs's peaked at 13.
    • The synchronous processes took 0.79 to 1.63 times s3fs's CPU time for the transfers at concurrency 8, and 1.25 to 2.30 times at concurrency 40.
  5. Requests sent one at a time.
    • With concurrency 1, cat took 84 ms per object with S3FileSystem, 76 ms with AioS3FileSystem, and 68 ms with s3fs.
    • With concurrency 8, a lane took 32 to 33 ms per object with both PyAthena APIs and 47 ms with s3fs, so with every API a request sent alone took 1.5 to 2.6 times as long as a request of a lane.
    • The run did not isolate the cause.

The two entries also leave the measurement itself open:

  • Neither estimates the variation between runs.
    The runs were on hosts in different Availability Zones, and s3fs's throughput at concurrency 40 changed between them, from 185 to 307 objects per second for cat, 205 to 380 for get, 222 to 438 for put, and 235 to 504 for pipe, while the aio filesystem's stayed within 0.88 to 1.02 times of the first run in the same operations.
  • Only objects of 1 MiB were measured.

Plan

  1. Count the S3 requests, by operation, that each API sends for get, cat, copy, and info() over the medium set.
  2. Profile get and info() at concurrency 40 on Python 3.12 to find where the CPU time goes.
  3. Add a set of smaller objects to the objects suite, for example 1,000 objects of 64 KiB.
  4. When work on 5.0.0 starts, run the comparison, with the concurrency-1 queue, in at least two runs on separate hosts to estimate the variation between runs.
  5. Record the results in a history entry, and file an issue for each gap whose cause is found, as Run the batch operations of S3FileSystem concurrently #1322 and Download in parallel ranges in get_file() #1323 were filed after the first run.

Done when

Each of the five gaps has a measured cause and a filed issue, or measurements that show it does not reproduce, and the history entry is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions