Skip to content

ExtensionBasedMapper is slow for large directories #333

Closed

Description

@rubensworks

I've setup the server over a directory with 309.978 very small N-Quads files (~10 triples per file). (same as in #332)
Every request to a single file takes 1 - 1,5 seconds, which is quite long.

The root cause seems to reading the directory upon every request: https://github.com/solid/community-server/blob/master/src/storage/ExtensionBasedMapper.ts#L97

Since this mapper depends on globbing, there's probably no good way around this.
A partial solution might be to place an (LRU-)cache over readdir, but this may then lead to memory issues for many large directories.

Alternatively, a set of whitelisted extensions could be configured, so that the mapper can loop over these extensions, which would allow specific files to be tested instead of reading the whole directory.
Downside is that these extensions would have to be preconfigured, so we'd lose generality (would solve my use case here though 😄).

So I guess this performance issue with large directories is inherent to this mapping strategy,
and probably just needs to be documented as a warning.

Activity

  1. RubenVerborgh commented on Nov 18, 2020

    @RubenVerborgh
  2. RubenVerborgh commented on Nov 18, 2020

    @RubenVerborgh
  3. RubenVerborgh commented on Nov 18, 2020

    @RubenVerborgh
    Member

    So I guess this performance issue with large directories is inherent to this mapping strategy

    The extension-based mapper implements https://www.w3.org/DesignIssues/HTTPFilenameMapping.html, which is a specific combination of trade-offs.

    Concretely, it is deemed important that:

    • we can have extensionless URLs
    • while storing the file type in the on-disk filename itself (as opposed to in an auxiliary file)
    • such that the on-disk extension matches the content type, for easy opening of files on a desktop

    These points are prioritized over performance with that mapping.

    If performance is more important, or if storing extensions on the filesystem is not important at all, there are better trade-offs.

    So my conclusion is: this mapper works as expected (even though minor performance improvements might be possible); a use case where large numbers of files in a folder are needed, might benefit from a mapping strategy that instead prioritizes performance. My suggestion is to implement such as a strategy as a separate component.

  4. added
    wontfix
    on Nov 18, 2020
  5. added a commit that references this issue on Nov 23, 2020
    a05b085
  6. added a commit that references this issue on Nov 23, 2020
    1438fd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

wontfix🐌 performance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions