Repository navigation
Release completed statement temporaries before exit-hook workloads #35
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
Merged
+85
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # A final class body creates temporary conversion errors, then exit hooks | ||
| # perform repeated collections. Count retained errors and time the actual GC. | ||
| count = Integer(ARGV.fetch(0, '20000')) | ||
| rounds = Integer(ARGV.fetch(1, '20')) | ||
| at_exit do | ||
| GC.enable | ||
| GC.start | ||
| warn "retained_errors=#{ObjectSpace.each_object(Encoding::UndefinedConversionError).count}" | ||
| start = Process.clock_gettime(Process::CLOCK_MONOTONIC) | ||
| rounds.times { GC.start } | ||
| warn "collections=#{rounds} seconds=#{Process.clock_gettime(Process::CLOCK_MONOTONIC) - start}" | ||
| p ExitGCWorkload.new.kept | ||
| end | ||
| GC.disable | ||
| Object.const_set(:EXIT_GC_INPUT, count) | ||
| class ExitGCWorkload | ||
| def self.build | ||
| codepoints = Array.new(EXIT_GC_INPUT) { |i| (0x1000 + i % 0x1000).chr('UTF-8') }.select do |code| | ||
| begin | ||
| code.encode('US-ASCII') | ||
| true | ||
| rescue Encoding::UndefinedConversionError | ||
| false | ||
| end | ||
| end | ||
| define_method(:kept) { codepoints } | ||
| end | ||
| build | ||
| end |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Exit hooks must keep captured values, but not every temporary allocated by | ||
| # the program's final statement. A conservative collector may retain a few | ||
| # incidental handles; retaining most of this completed workload is a leak. | ||
| at_exit do | ||
| GC.enable | ||
| GC.start | ||
| p ObjectSpace.each_object(Encoding::UndefinedConversionError).count < 1000 | ||
| p ExitRootFixture.new.kept | ||
| end | ||
| GC.disable | ||
|
|
||
| class ExitRootFixture | ||
| def self.build | ||
| kept = ['kept', {answer: [42]}] | ||
| selected = (0..4000).map { |i| (i + 0x1000).chr('UTF-8') }.select do |code| | ||
| begin | ||
| code.encode('US-ASCII') | ||
| true | ||
| rescue Encoding::UndefinedConversionError | ||
| false | ||
| end | ||
| end | ||
| define_method(:kept) { [kept, selected] } | ||
| end | ||
| build | ||
| end | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.