-
Notifications
You must be signed in to change notification settings - Fork 1
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
reduce memory consumption #47
Merged
romainmenke
merged 16 commits into
main
from
reduce-memory-consumption--rational-bull-terrier-d4ef3d281a
Oct 8, 2024
Merged
reduce memory consumption #47
romainmenke
merged 16 commits into
main
from
reduce-memory-consumption--rational-bull-terrier-d4ef3d281a
Oct 8, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…281a' of https://github.com/mrhenry/polyfill-library into reduce-memory-consumption--rational-bull-terrier-d4ef3d281a
romainmenke
commented
Jul 1, 2024
Comment on lines
-117
to
-130
describe('sources.listPolyfills()', () => { | ||
it('returns a promise which resolves with an array containing names for each polyfilled feature', () => { | ||
const sources = require('../../../lib/sources'); | ||
return sources.listPolyfills().then((result) => { | ||
assert.ok(Array.isArray(result)); | ||
assert.ok(result.length > 0); | ||
assert.deepStrictEqual(result[0], 'AbortController'); | ||
assert.equal( | ||
result.filter(x => (typeof x === 'string')).length, | ||
result.length | ||
); | ||
}); | ||
}); | ||
}); |
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.
This test existed twice
…tion--rational-bull-terrier-d4ef3d281a
…tion--rational-bull-terrier-d4ef3d281a
mhassan1
approved these changes
Oct 8, 2024
romainmenke
deleted the
reduce-memory-consumption--rational-bull-terrier-d4ef3d281a
branch
October 8, 2024 06:34
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
see : #37
The current implementation of reading files and creating polyfill bundles doesn't really make sense.
It is both streaming and cached.
These are not things you can/should combine.
Either you make something streaming because you are concerned about memory usage.
Or you have a cache and try to serve directly from memory.
So the current implementation is needlessly complex while also being slow and using too much memory.
The slowness is mostly the result of having too many cache misses and an implementation that is way too complex for what is actually going on.
This change:
meta.json
files for all polyfills and lazily loading this in memorymeta.json
fs
functions user configurableConfigurable
fs
functions:This is a replacement for those users who want caching or other optimizations.
I don't want to add an explicit cache mechanic as I still believe that an in memory cache implemented in JavaScript is dangerous when running this as a hosted service.
It is too easy to request different polyfills one by one, thrashing both the
LRU
cache layer and the garbage collector to eventually starve the host of both memory and CPU.Either you want to have an edge cache in front of a hosted service (making in memory cache less relevant) or you want to use something like sqlite to optimize filesystem reads.
I don't consider the removal of the
LRU
cache a breaking change because this was an internal implementation detail. But I am open to other opinions here :)