openvsx
openvsx copied to clipboard
Add Spring caching
We should add spring caching on the most frequently fetched resources.
Fixing the download count (issue #283), a priority, is dependent on this issue.
@svenefftinge
- This is server side caching only? I see other issues already worked on setting caching headers in the HTTP response.
- Is there a list of most frequently fetched resources? It looks like issue #266 has some hints on what to cache.
@brianking This relates to caching database query results (and other heavy computations) internally in the server using Spring Caching. My bad, I misunderstood the issue at first.
Could this be a good opportunity to look for database related performance issues in general?
Yes, I'm sure there are plenty of code parts that can be optimized w.r.t. DB access performance. Currently both the server and DB have super high CPU load in production (especially if we decrease LB caching), which indicates that we send too many and too complex DB queries.
This was my first project with Spring and JPA/Hibernate. I must say I would never start a project with JPA again, but evaluate SQL-first approaches like jOOQ instead. Maybe it's even worth refactoring the whole server app to drop JPA entirely.
@amvanbaren what Miro said! However, a refactoring might be too large a time commitment at this point. Feel free to try some optimizations, however, and to recommend approaches moving forward.
Hibernate fetches @ManyToOne and @OneToOne mappings eagerly. The effect is most pronounced for ExtensionVersion queries. In this case the Extension, Namespace, PersonalAccessToken and UserData are also loaded.
Changing @ManyToOne to @ManyToOne(fetch=FetchType.LAZY) or @OneToOne to @OneToOne(fetch=FetchType.LAZY) or adding @Basic(fetch=FetchType.LAZY) to enable lazy loading has no effect.
Any ideas why lazy loading is ignored?
I'm currently working on implementing projections/dtos to speed up the /vscode/gallery/extensionquery endpoint.
https://github.com/eclipse/openvsx/blob/d72fb0fe5361c0775f3b6fbc13bbbadf0fe9ff79/server/src/main/java/org/eclipse/openvsx/adapter/VSCodeAdapter.java#L312-L314
Is it possible to create public ids before the extensionquery endpoint is called?
Is it possible to create public ids before the extensionquery endpoint is called?
Yes, we could create them when an extension is published instead of when it's accessed in extensionquery results.
Ok good, In PR #350 I've moved the creation of public ids to ExtensionService.createExtensionVersion when a new Extension is created.
I'm closing this issue. If there are still performance/caching issues, please open a new issue for a specific endpoint with a test case.