Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

[feature] create BEP connection on demands instead of keeping it as a service #356

Merged
merged 2 commits into from
Mar 13, 2023

Conversation

tpasternak
Copy link
Contributor

@tpasternak tpasternak commented Mar 10, 2023

Background

Significantly reduces memory footprint of the application, because the
never-cleaned BepServer instance was holding a BepOutputBuilder bepOutputBuilder
field which in turn was holding all BEP messages that has been received since the
prevous build.

So the reason for this change is:

  1. There's no point of having a socket handle and other sources laying in memory,
    in particular because it's easy to make a mistake of keeping too much data.
  2. BepServer setup is cheap
  3. It will be easier to provide different peb handlers for different calls.

Memory footprint comparison

The heap size in of this app in idle, for a project containing 2000 targets, is reduced from
more than ~2GB to ~0.5GB.

Bazel BSP 2.5.1 (idle, after 2000k targets import)

$ jcmd 11429 GC.heap_info
11429:
 garbage-first heap   total 5382144K, used 3219933K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 40 young (163840K), 39 survivors (159744K)
 Metaspace       used 45658K, committed 46016K, reserved 1097728K
  class space    used 5045K, committed 5248K, reserved 1048576K
$ jcmd 11429 GC.run
11429:
Command executed successfully
$ jcmd 11429 GC.heap_info
11429:
 garbage-first heap   total 5382144K, used 2161982K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 45658K, committed 46016K, reserved 1097728K
  class space    used 5045K, committed 5248K, reserved 1048576K

Bazel BSP now:

$ jcmd 9381 GC.heap_info
9381:
 garbage-first heap   total 4001792K, used 2190915K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 48 young (196608K), 47 survivors (192512K)
 Metaspace       used 46417K, committed 46784K, reserved 1097728K
  class space    used 5114K, committed 5312K, reserved 1048576K
$ jcmd 9381 GC.run
9381:
Command executed successfully
$ jcmd 9381 GC.heap_info
9381:
 garbage-first heap   total 1900544K, used 556282K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 46417K, committed 46784K, reserved 1097728K
  class space    used 5114K, committed 5312K, reserved 1048576K

Formatting

Seems like the CI "format" job fails for this commit, but it's unrelated to the changes included in this PR. Should be addressed in a separate PR

- Background
Significantly reduces memory footprint of the application, because the
never-cleaned BepServer instance was holding a `BepOutputBuilder bepOutputBuilder`
field which in turn was holding all BEP messages that has been received since the
prevous build.

So the reason for this change is:
1. There's no point of having a socket handle and other sources laying in memory,
   in particular because it's easy to make a mistake of keeping too much data.
2. BepServer setup is cheap
3. It will be easier to provide different peb handlers for different calls.

- Memory footprint comparison
The heap size in of this app in idle, for a project containing 2000 targets, is reduced from
more than ~2GB to ~0.5GB.

Bazel BSP 2.5.1 (idle, after 2000k targets import)
```
$ jcmd 11429 GC.heap_info
11429:
 garbage-first heap   total 5382144K, used 3219933K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 40 young (163840K), 39 survivors (159744K)
 Metaspace       used 45658K, committed 46016K, reserved 1097728K
  class space    used 5045K, committed 5248K, reserved 1048576K
$ jcmd 11429 GC.run
11429:
Command executed successfully
$ jcmd 11429 GC.heap_info
11429:
 garbage-first heap   total 5382144K, used 2161982K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 45658K, committed 46016K, reserved 1097728K
  class space    used 5045K, committed 5248K, reserved 1048576K

```

Bazel BSP now:
```
$ jcmd 9381 GC.heap_info
9381:
 garbage-first heap   total 4001792K, used 2190915K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 48 young (196608K), 47 survivors (192512K)
 Metaspace       used 46417K, committed 46784K, reserved 1097728K
  class space    used 5114K, committed 5312K, reserved 1048576K
$ jcmd 9381 GC.run
9381:
Command executed successfully
$ jcmd 9381 GC.heap_info
9381:
 garbage-first heap   total 1900544K, used 556282K [0x0000000673800000, 0x0000000800000000)
  region size 4096K, 0 young (0K), 0 survivors (0K)
 Metaspace       used 46417K, committed 46784K, reserved 1097728K
  class space    used 5114K, committed 5312K, reserved 1048576K

```
@tpasternak tpasternak changed the title wip Create BEP connection on demands instead of keeping it as a service Mar 13, 2023
@tpasternak tpasternak marked this pull request as ready for review March 13, 2023 10:59
Copy link
Member

@abrams27 abrams27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls update the changelog

@abrams27 abrams27 changed the title Create BEP connection on demands instead of keeping it as a service [feature] create BEP connection on demands instead of keeping it as a service Mar 13, 2023
@tpasternak tpasternak merged commit 4252736 into JetBrains:master Mar 13, 2023
@tpasternak tpasternak deleted the bep-server-on-demand branch March 13, 2023 13:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants