Project

General

Profile

Actions

Bug #15797

closed

Use `extends AnyVal` and remove HashCodeCaching for classes with one parameter

Added by François ARMAND about 5 years ago. Updated about 5 years ago.

Status:
Released
Priority:
N/A
Category:
Performance and scalability
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
Fix check:
To do
Regression:

Description

See https://docs.scala-lang.org/overviews/core/value-classes.html#summary_of_limitations

=> most of our IDs are suitable. May lead to far less pressure on GC.

Limitation are:

 
A value class …
 … must have only a primary constructor with exactly one public, val parameter whose type is not a user-defined value class. (From Scala 2.11.0, the parameter may be non-public.)
 … may not have specialized type parameters.
 … may not have nested or local classes, traits, or objects
 … may not define a equals or hashCode method.
 … must be a top-level class or a member of a statically accessible object
 … can only have defs as members. In particular, it cannot have lazy vals, vars, or vals as members.
 … cannot be extended by another class.

We also need to remove hashcodeCaching as the general feedback for it is that the JVM knows what it does on hashcode which is perhaps the most optimized code in it, and having a lazy val (or val) forced calculated at object creation has major perf impact.


Subtasks 1 (0 open1 closed)

Bug #15966: Changing hashcode changes order in map, which breaks write testReleasedNicolas CHARLESActions

Related issues 1 (0 open1 closed)

Related to Rudder - Bug #15965: Trying to make LdapEntry immutable broke rudder - revertingReleasedNicolas CHARLESActions
Actions #1

Updated by François ARMAND about 5 years ago

  • Status changed from New to In progress
  • Assignee set to François ARMAND
Actions #2

Updated by François ARMAND about 5 years ago

  • Subject changed from Use `extends AnyVal` for case classes with one parameter to Use `extends AnyVal` and remove HashCodeCaching for classes with one parameter
  • Description updated (diff)
  • Category deleted (Performance and scalability)
  • Target version deleted (5.0.14)
  • Name check deleted (To do)
Actions #3

Updated by François ARMAND about 5 years ago

  • Category set to Performance and scalability
  • Target version set to 5.0.14
Actions #5

Updated by François ARMAND about 5 years ago

  • Status changed from In progress to Pending technical review
  • Assignee changed from François ARMAND to Nicolas CHARLES
  • Pull Request set to https://github.com/Normation/rudder/pull/2484
Actions #7

Updated by Vincent MEMBRÉ about 5 years ago

  • Target version changed from 5.0.14 to 5.0.15
Actions #8

Updated by François ARMAND about 5 years ago

  • Status changed from Pending technical review to Pending release
Actions #9

Updated by Vincent MEMBRÉ about 5 years ago

  • Target version changed from 5.0.15 to 6.0.0~beta1
Actions #10

Updated by Vincent MEMBRÉ about 5 years ago

This bug fix was moved to 6.0 and not to 5.0 because it breaks plugin api

rudder|684a1ceeee3941c52e9c8797d2648d443a31f550 was reverted by rudder|9fe894c5.

revert was not merged to 6.0 by merge in strategy ours rudder|de3e7bce.

code in 6.0 branch is a mix of rudder|684a1ceeee3941c52e9c8797d2648d443a31f550 and previous merge commit rudder|de3e7bce .

Actions #11

Updated by Vincent MEMBRÉ about 5 years ago

This bug has been fixed in Rudder 6.0.0~beta1 which was released today.

Actions #12

Updated by Vincent MEMBRÉ about 5 years ago

  • Related to Bug #15965: Trying to make LdapEntry immutable broke rudder - reverting added
Actions #13

Updated by Vincent MEMBRÉ about 5 years ago

  • Status changed from Pending release to Released
Actions

Also available in: Atom PDF