Bug 191621 - Add cache for CommitLog objects to avoid refetching same commit.
Summary: Add cache for CommitLog objects to avoid refetching same commit.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: dewei_zhu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-13 20:25 PST by dewei_zhu
Modified: 2018-11-13 23:37 PST (History)
2 users (show)

See Also:


Attachments
Patch (14.11 KB, patch)
2018-11-13 20:32 PST, dewei_zhu
no flags Details | Formatted Diff | Diff
Patch (15.41 KB, patch)
2018-11-13 21:19 PST, dewei_zhu
no flags Details | Formatted Diff | Diff
Patch (18.40 KB, patch)
2018-11-13 22:32 PST, dewei_zhu
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dewei_zhu 2018-11-13 20:25:25 PST
Add cache for CommitLog objects to avoid refetching same commit.
Comment 1 dewei_zhu 2018-11-13 20:32:50 PST
Created attachment 354760 [details]
Patch
Comment 2 Ryosuke Niwa 2018-11-13 20:43:48 PST
Comment on attachment 354760 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354760&action=review

> Websites/perf.webkit.org/ChangeLog:11
> +        (CommitLog): Added assertion for id. Removed unused 'remoteId'.

Refer to r198479 where the relevant code was removed.

> Websites/perf.webkit.org/public/v3/models/commit-log.js:174
> +        const commit = this.ensureNamedStaticMap(`repository-${repository.id()}`)[revision];

ensureNamedStaticMap shouldn't be called with a dynamically generated name like this because it would be slow.
In general, ensureNamedStaticMap is designed to work with a small fixed number of maps.

Instead, this.ensureNamedStaticMap('repositoryMap') should have a map.
Maybe an even better design is for each instance of a Repository object to have this map
although it's slightly inelegant to reference CommitLog and Repository like that.
Comment 3 dewei_zhu 2018-11-13 21:19:12 PST
Created attachment 354765 [details]
Patch
Comment 4 Ryosuke Niwa 2018-11-13 21:42:24 PST
Comment on attachment 354765 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354765&action=review

> Websites/perf.webkit.org/public/v3/models/commit-log.js:174
> +        const commit = repository.ensureNamedStaticMap('revision')[revision];

Oh, no, that's not what I mean. ensureNamedStaticMap is per class so this is simply an alias to Repository.ensureNamedStaticMap('revision')
You'd have to create your own instance variable on Repository. Please add a test for this.
If you called fetchForSingleRevision on two different repositories, it would override each other with the current patch.
Comment 5 dewei_zhu 2018-11-13 22:32:46 PST
Created attachment 354772 [details]
Patch
Comment 6 Ryosuke Niwa 2018-11-13 22:54:55 PST
Comment on attachment 354772 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354772&action=review

> Websites/perf.webkit.org/ChangeLog:12
> +        Removed unused 'remoteId' has it has been removed since r198479.

s/has it has/as it has/

> Websites/perf.webkit.org/public/v3/models/repository.js:38
> +

No need for a blank line here.
Comment 7 dewei_zhu 2018-11-13 23:37:13 PST
Landed in r238167