You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "ekaterinadimitrova2 (via GitHub)" <gi...@apache.org> on 2023/07/21 21:43:10 UTC
[GitHub] [cassandra] ekaterinadimitrova2 commented on a diff in pull request #2488: CASSANDRA-18329: Upgrade Jamm
ekaterinadimitrova2 commented on code in PR #2488:
URL: https://github.com/apache/cassandra/pull/2488#discussion_r1270721681
##########
src/java/org/apache/cassandra/audit/BinAuditLogger.java:
##########
@@ -98,6 +99,11 @@ public void log(AuditLogEntry auditLogEntry)
@VisibleForTesting
public static class Message extends BinLog.ReleaseableWriteMarshallable implements WeightedQueue.Weighable
{
+ /**
+ * The shallow size of a {@code Query} object.
Review Comment:
* The shallow size of a {@code Message} object.
##########
src/java/org/apache/cassandra/fql/FullQueryLogger.java:
##########
@@ -366,17 +366,21 @@ public void writeMarshallablePayload(WireOut wire)
@Override
public int weight()
{
- return Ints.checkedCast(EMPTY_SIZE + ObjectSizes.sizeOf(query) + super.fielsdSize());
+ // Object deep size = Object' shallow size + query field deep size + deep size of the parent fields
+ return Ints.checkedCast(EMPTY_SIZE + ObjectSizes.sizeOf(query) + super.fieldsSize());
}
}
public static class Batch extends AbstractLogEntry
{
/**
- * The shallow size of a {@code Batch} object.
+ * The shallow size of a {@code Batch} object (which includes primitive fields).
*/
private static final long EMPTY_SIZE = ObjectSizes.measure(new Batch());
+ /**
+ * The way is pre-computed in the constructor and represent the object deep size.
Review Comment:
* The weight is pre-computed in the constructor and represents the object's deep size.
##########
src/java/org/apache/cassandra/fql/FullQueryLogger.java:
##########
@@ -508,16 +545,14 @@ public void release()
queryOptionsBuffer.release();
}
- @Override
- public int weight()
+ /**
+ * Returns the sum of the non primitive fields sizes.
+ * @return the sum of the non primitive fields sizes.
+ */
+ protected long fielsdSize()
{
- return OBJECT_HEADER_SIZE
- + Long.BYTES // queryStartTime
- + Integer.BYTES // protocolVersion
- + OBJECT_REFERENCE_SIZE + EMPTY_BYTEBUF_SIZE + queryOptionsBuffer.capacity() // queryOptionsBuffer
- + Long.BYTES // generatedTimestamp
- + Long.BYTES // generatedNowInSeconds
- + OBJECT_REFERENCE_SIZE + Ints.checkedCast(ObjectSizes.sizeOf(keyspace)); // keyspace
+ return EMPTY_BYTEBUF_SIZE + queryOptionsBuffer.capacity() // queryOptionsBuffer
+ + ObjectSizes.sizeOf(keyspace); // keyspace
Review Comment:
Thanks for the additional comments, adding stuff separately is quite confusing even after looking into the MemoreMeter for months.... :(
##########
src/java/org/apache/cassandra/utils/ObjectSizes.java:
##########
@@ -105,15 +98,12 @@ public static long sizeOfReferenceArray(int length)
*/
public static long sizeOfArray(Object[] objects)
{
- if (objects == null)
- return 0;
-
- return sizeOfReferenceArray(objects.length);
+ return meter.measureArray(objects);
Review Comment:
My understanding is measureArray is doing what sizeOfReferenceArray (thus the change you did here) is doing so I was wondering why then we do not replace all usages of sizeOfReferenceArray with measureArray? But now on a second read I see I misread, sizeOfReferenceArray is provided length...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org