-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use hashed folder names instead of filenames. closes #6232 #8808
Conversation
expect(result.src.indexOf(file.name)).toBe(8) | ||
expect(result.srcSet.indexOf(file.name)).toBe(8) | ||
expect(result.src.indexOf(file.name)).toBe(19) | ||
expect(result.srcSet.indexOf(file.name)).toBe(19) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those had to be changed because the strings changed from:
/static/test-1234-7bb67.png
to
/static/1234/7bb67/test.png
So now file name starts at index 19
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should adjust this test to test that final part of path is same as source file? i.e.
expect(path.parse(result.src).name).toBe(file.name)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and similiar with srcSet
- probably would need some processing to split by ,
and then space or something like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo hoo; this looks great, thank you!
|
(gatsbyjs#8808) **Related issue:** gatsbyjs#6232 @LekoArts mentioned two ways of implementing it (one that concatenates `argsDigest` with `contentDigest` and other that uses `contentDigest` as one directory and `argsDigest` as another child so images are grouped together and it limits the number of directories in `static` directory). This PR implements the latter. ### Performance impact I measured the performance of original solution and one from this PR 5 times (and ignoring first build after changing gatsby version) for each (every time cleaning the cache) by running `gatsby build` on example [using-gatsby-image](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-gatsby-image). Tested on Linux, Ryzen 2700X and 970 EVO. #### Original (`2.0.18`) - `14.70` - `14.08` - `13.65` - `14.22` - `13.80` **Average:** `14.09` #### This PR: - `13.77` - `13.51` - `13.61` - `13.78` - `13.66` **Average:** `13,666` So this results in 3% improvement in build times (it might be just luck, but at least it doesn't increase build time).
Related issue: #6232
@LekoArts mentioned two ways of implementing it (one that concatenates
argsDigest
withcontentDigest
and other that usescontentDigest
as one directory andargsDigest
as another child so images are grouped together and it limits the number of directories instatic
directory). This PR implements the latter.Performance impact
I measured the performance of original solution and one from this PR 5 times (and ignoring first build after changing gatsby version) for each (every time cleaning the cache) by running
gatsby build
on example using-gatsby-image.Tested on Linux, Ryzen 2700X and 970 EVO.
Original (
2.0.18
)14.70
14.08
13.65
14.22
13.80
Average:
14.09
This PR:
13.77
13.51
13.61
13.78
13.66
Average:
13,666
So this results in 3% improvement in build times (it might be just luck, but at least it doesn't increase build time).