Skip to content

Improve caching behavior #55

@tuner

Description

@tuner

Hi,

I'm loading BigWig data for the whole genome, i.e., calling getFeatures for each chromosome. This results in many fetch requests, as expected.

GC

However, the number of requests seems to be excessive (76), and many of them hit exactly the same range. For example, in the above case (https://genomespy.app/docs/grammar/data/lazy/#example_1), there are 25 requests hitting the same 49 byte range and other 25 requests hitting a same 8197 range. Because web browsers seem to be very bad at caching partial content, this results in quite a bit of latency.

There appears to be a caching mechanism in BlockView, but a new BlockView (and cache) is created for each getFeatures call.

private featureCache = new AbortablePromiseCache<ReadData, Buffer>({

Instead of having a new cache for each BlockView, could there be a single shared cache in the BBI class, which could be used by all BlockViews? In my example case, the number of requests would drop from 76 to 28.

I could make a PR at some point if this change is feasible and would not cause any undesired adverse effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions