1
0
Fork 0
hugo/resources
Bjørn Erik Pedersen 208a0de6c3 tpl: Add a partial lookup cache
````
                 │ stash.bench  │          perf-v146.bench           │
                 │    sec/op    │   sec/op     vs base               │
LookupPartial-10   248.00n ± 0%   14.75n ± 2%  -94.05% (p=0.002 n=6)

                 │ stash.bench │          perf-v146.bench          │
                 │    B/op     │   B/op     vs base                │
LookupPartial-10    48.00 ± 0%   0.00 ± 0%  -100.00% (p=0.002 n=6)

                 │ stash.bench │          perf-v146.bench           │
                 │  allocs/op  │ allocs/op   vs base                │
LookupPartial-10    3.000 ± 0%   0.000 ± 0%  -100.00% (p=0.002 n=6)
```

THe speedup above assumes reuse of the same partials over and over again, which I think is not uncommon.

This commits also adds some more lookup benchmarks. The current output of these on my MacBook looks decent:

```
BenchmarkLookupPagesLayout/Single_root-10                3031562               395.5 ns/op             0 B/op          0 allocs/op
BenchmarkLookupPagesLayout/Single_sub_folder-10          2515915               480.9 ns/op             0 B/op          0 allocs/op
BenchmarkLookupPartial-10                               84808112                14.13 ns/op            0 B/op          0 allocs/op
BenchmarkLookupShortcode/toplevelpage-10                 8111779               148.2 ns/op             0 B/op          0 allocs/op
BenchmarkLookupShortcode/nestedpage-10                   8088183               148.6 ns/op             0 B/op          0 allocs/op
```

Note that in the above the partial lookups are cahced, the others not (they are harder to cache because of the page path).

Closes #13571
2025-04-10 11:07:19 +02:00
..
assets Create a struct with all of Hugo's config options 2023-05-16 18:01:29 +02:00
images resources/image: Mark loong64 as FMA-using architecture 2025-02-26 21:17:06 +01:00
internal Consolidate all hashing to the common/hashing package 2024-07-31 16:44:06 +02:00
jsconfig all: Fix typos in function names and comments 2023-06-19 09:26:29 +02:00
kinds Reimplement and simplify Hugo's template system 2025-04-06 20:59:41 +02:00
page tpl: Add a partial lookup cache 2025-04-10 11:07:19 +02:00
postpub all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
resource all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
resource_factories tpl: Add templates.Current 2025-04-09 20:15:40 +02:00
resource_transformers Reimplement and simplify Hugo's template system 2025-04-06 20:59:41 +02:00
testdata resources: Fix 2 image file cache key issues 2025-01-18 12:23:18 +01:00
docs.go all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning 2024-01-27 16:28:14 +01:00
image.go resources: Fix 2 image file cache key issues 2025-01-18 12:23:18 +01:00
image_cache.go resources: Fix 2 image file cache key issues 2025-01-18 12:23:18 +01:00
image_extended_test.go all: Remove deprecated build tags 2025-02-08 10:29:42 +01:00
image_test.go all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
post_publish.go Add basic "post resource publish support" 2020-04-07 21:59:20 +02:00
resource.go resources: Fix 2 image file cache key issues 2025-01-18 12:23:18 +01:00
resource_cache.go Fix same resource file published more than once 2024-12-27 18:55:24 +01:00
resource_metadata.go all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
resource_spec.go Reimplement and simplify Hugo's template system 2025-04-06 20:59:41 +02:00
resource_spec_test.go all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning 2024-01-27 16:28:14 +01:00
resource_test.go Add js.Batch 2024-12-12 21:43:17 +01:00
resources_integration_test.go all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
testhelpers_test.go resource: Revert the normalization of Resource.Name 2024-02-25 14:57:29 +01:00
transform.go resources: Remove debug statement 2025-01-30 11:32:57 +01:00
transform_integration_test.go all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning 2024-01-27 16:28:14 +01:00
transform_test.go all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00