Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • asm asm
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • asmasm
  • asmasm
  • Merge requests
  • !183

WIP: Make ClassWriter reusable

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Jason Zaugg requested to merge retronymm/asm:topic/buffer-reuse into master Jun 13, 2018
  • Overview 8
  • Commits 7
  • Pipelines 15
  • Changes 6

Adds a clear() method to ClassWriter to allow the user to reuse it to write another class without needing to allocate new buffers for the constant pool, etc.

Furthermore, add a mode that enabled internal reuse of of buffers class writing.

Exposes an overload of toByteArray that does not require a copy of the internal buffer, but rather returns the ByteVector directly. ByteVector has been updated to expose its contents in a read-only manner as a ByteBuffer or a ByteArrayInputStream.

I've made an initial attempt to include this in the benchmark framework.

 # VM version: JDK 1.8.0_162, VM 25.162-b12
Benchmark                                                          Mode  Cnt        Score       Error   Units
GeneratorBenchmark.asm6_1                                         thrpt   20   874896.336 ± 10360.316   ops/s
GeneratorBenchmark.asm6_1:+memory.used                            thrpt   20          ≈ 0               bytes
GeneratorBenchmark.asm6_1:·gc.alloc.rate                          thrpt   20     2777.524 ±    31.962  MB/sec
GeneratorBenchmark.asm6_1:·gc.alloc.rate.norm                     thrpt   20     5000.001 ±     0.003    B/op
GeneratorBenchmark.asm6_1:·gc.churn.PS_Eden_Space                 thrpt   20     2689.738 ±    71.334  MB/sec
GeneratorBenchmark.asm6_1:·gc.churn.PS_Eden_Space.norm            thrpt   20     4841.558 ±   101.258    B/op
GeneratorBenchmark.asm6_1:·gc.churn.PS_Survivor_Space             thrpt   20        0.162 ±     0.044  MB/sec
GeneratorBenchmark.asm6_1:·gc.churn.PS_Survivor_Space.norm        thrpt   20        0.291 ±     0.079    B/op
GeneratorBenchmark.asm6_1:·gc.count                               thrpt   20      264.000              counts
GeneratorBenchmark.asm6_1:·gc.time                                thrpt   20      176.000                  ms
GeneratorBenchmark.asm6_1_reuse                                   thrpt   20  1053280.540 ± 38925.306   ops/s
GeneratorBenchmark.asm6_1_reuse:+memory.used                      thrpt   20          ≈ 0               bytes
GeneratorBenchmark.asm6_1_reuse:·gc.alloc.rate                    thrpt   20     1525.059 ±    56.375  MB/sec
GeneratorBenchmark.asm6_1_reuse:·gc.alloc.rate.norm               thrpt   20     2280.001 ±     0.002    B/op
GeneratorBenchmark.asm6_1_reuse:·gc.churn.PS_Eden_Space           thrpt   20     1455.204 ±    57.245  MB/sec
GeneratorBenchmark.asm6_1_reuse:·gc.churn.PS_Eden_Space.norm      thrpt   20     2175.987 ±    47.373    B/op
GeneratorBenchmark.asm6_1_reuse:·gc.churn.PS_Survivor_Space       thrpt   20        0.171 ±     0.046  MB/sec
GeneratorBenchmark.asm6_1_reuse:·gc.churn.PS_Survivor_Space.norm  thrpt   20        0.257 ±     0.070    B/op
GeneratorBenchmark.asm6_1_reuse:·gc.count                         thrpt   20      248.000              counts
GeneratorBenchmark.asm6_1_reuse:·gc.time                          thrpt   20      166.000                  ms
 # VM version: JDK 10.0.1, VM 10.0.1+10
Benchmark                                                                         Mode  Cnt       Score      Error   Units
GeneratorBenchmark.asm6_1                                                        thrpt   20  808490.379 ± 9597.741   ops/s
GeneratorBenchmark.asm6_1:·gc.alloc.rate                                         thrpt   20    2567.604 ±   30.110  MB/sec
GeneratorBenchmark.asm6_1:·gc.alloc.rate.norm                                    thrpt   20    5000.001 ±    0.002    B/op
GeneratorBenchmark.asm6_1:·gc.churn.CodeHeap_'non-profiled_nmethods'             thrpt   20       0.008 ±    0.002  MB/sec
GeneratorBenchmark.asm6_1:·gc.churn.CodeHeap_'non-profiled_nmethods'.norm        thrpt   20       0.016 ±    0.004    B/op
GeneratorBenchmark.asm6_1:·gc.churn.G1_Old_Gen                                   thrpt   20    2574.135 ±   84.224  MB/sec
GeneratorBenchmark.asm6_1:·gc.churn.G1_Old_Gen.norm                              thrpt   20    5012.769 ±  155.361    B/op
GeneratorBenchmark.asm6_1:·gc.count                                              thrpt   20     235.000             counts
GeneratorBenchmark.asm6_1:·gc.time                                               thrpt   20     250.000                 ms
GeneratorBenchmark.asm6_1_reuse                                                  thrpt   20  874917.363 ± 2517.632   ops/s
GeneratorBenchmark.asm6_1_reuse:·gc.alloc.rate                                   thrpt   20    1266.731 ±    4.102  MB/sec
GeneratorBenchmark.asm6_1_reuse:·gc.alloc.rate.norm                              thrpt   20    2280.001 ±    0.002    B/op
GeneratorBenchmark.asm6_1_reuse:·gc.churn.CodeHeap_'non-profiled_nmethods'       thrpt   20       0.004 ±    0.002  MB/sec
GeneratorBenchmark.asm6_1_reuse:·gc.churn.CodeHeap_'non-profiled_nmethods'.norm  thrpt   20       0.008 ±    0.004    B/op
GeneratorBenchmark.asm6_1_reuse:·gc.churn.G1_Old_Gen                             thrpt   20    1266.407 ±   62.495  MB/sec
GeneratorBenchmark.asm6_1_reuse:·gc.churn.G1_Old_Gen.norm                        thrpt   20    2279.504 ±  113.687    B/op
GeneratorBenchmark.asm6_1_reuse:·gc.count                                        thrpt   20     144.000             counts
GeneratorBenchmark.asm6_1_reuse:·gc.time                                         thrpt   20     147.000                 ms
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: topic/buffer-reuse